package me.sdevil507.biz.fruit.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.extern.slf4j.Slf4j;
import me.sdevil507.biz.common.sysdict.po.SysDict;
import me.sdevil507.biz.common.sysdict.service.SysdictService;
import me.sdevil507.biz.fruit.dto.ConstantAnnotation;
import me.sdevil507.biz.fruit.dto.FruitDTO;
import me.sdevil507.biz.fruit.dto.FruitParamsDTO;
import me.sdevil507.biz.fruit.dto.exportDTO.*;
import me.sdevil507.biz.fruit.mapper.FruitMapper;
import me.sdevil507.biz.fruit.po.*;
import me.sdevil507.biz.fruit.repository.*;
import me.sdevil507.biz.fruit.service.FruitImportExportService;
import me.sdevil507.org.dto.ExpertSearchDto;
import me.sdevil507.org.po.TempExpertPo;
import me.sdevil507.org.service.TempExpertService;
import me.sdevil507.supports.excel.ExportExcel;
import me.sdevil507.supports.excel.ReflexObjectUtil;
import me.sdevil507.supports.result.ApiResultDTO;
import me.sdevil507.supports.result.ApiResultGenerator;
import me.sdevil507.supports.shiro.helper.OrgAccountHelper;
import me.sdevil507.supports.status.ApiStatusCode;
import me.sdevil507.supports.status.ComConstant;
import me.sdevil507.supports.util.CommonUtil;
import me.sdevil507.supports.util.RegularExpressionUtil;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Service
@Slf4j
public class FruitImportExportServiceImpl implements FruitImportExportService {

    @Resource
    private FruitServiceImpl fruitServiceImpl;
    @Resource
    private FruitRepository fruitRepository;
    @Resource
    private FruitOrgRelRepository fruitOrgRelRepository;
    @Resource
    private FruitAuthorRepository fruitAuthorRepository;
    @Resource
    private FruitAuthorOrgRepository fruitAuthorOrgRepository;
    @Resource
    private FruitSubRepository fruitSubRepository;
    @Resource
    private FruitLeaderRepository fruitLeaderRepository;
    @Resource
    private FruitMapper fruitMapper;

    @Autowired
    private SysdictService sysdictService;
    @Autowired
    private TempExpertService tempExpertService;

    @Override
    public ApiResultDTO importFruitByExcel(File file, String type, String activityProdType) {
        ApiResultDTO apiResultDTO;
        Workbook workbook = null;
        StringBuilder message = new StringBuilder();
        try {
            if (file.getPath().endsWith("xls")) {
                workbook = new HSSFWorkbook(new FileInputStream(file));
            } else if (file.getPath().endsWith("xlsx")) {
                workbook = new XSSFWorkbook(new FileInputStream(file));
            }
            // 获取第一个sheet
            Sheet sheet = workbook.getSheetAt(0);

            switch (type) {
//                case ComConstant.FruitType.ContinuityInformation:
//                    message = importContinuityInformation(message, sheet);
//                    break;
                case ComConstant.FruitType.InternalReferenceReport:
                    internalReferenceReportInformation(message, sheet);
                    break;
                case ComConstant.FruitType.REPORT:
                    reportInformation(message, sheet);
                    break;
                case ComConstant.FruitType.PolicyAdvice:
//                    message = policyAdviceInformation(message, sheet);
                    activityInformation(message, sheet, activityProdType);
                    break;
                case ComConstant.FruitType.NewspaperORNetwork:
                    newspaperORNetworkInformation(message, sheet, activityProdType);
                    break;
                case ComConstant.FruitType.Paper:
                    paperInformation(message, sheet);
                    break;
                case ComConstant.FruitType.BOOK:
                    bookInformation(message, sheet);
                    break;
                case ComConstant.FruitType.PRICE:
                    priceInformation(message, sheet);
                    break;
                case ComConstant.FruitType.PROJECT:
                    projectInformation(message, sheet, activityProdType);
                    break;
//                default:
//                    otherInformation(message, sheet);
            }
        } catch (Exception e) {
            e.printStackTrace();
            apiResultDTO = ApiResultGenerator.create("-1", "格式异常，请修改后再试！");
            return apiResultDTO;
        }
        if (message.length() == 0) {
            apiResultDTO = ApiResultGenerator.create(ApiStatusCode.SUCCESS.getCode(), "导入成果数据成功");
        } else {
            apiResultDTO = ApiResultGenerator.create("-1", message.toString());
        }

        return apiResultDTO;
    }


    /**
     * @param message
     * @param sheet
     * @ClassName FruitServiceImpi
     * @Description : 通过excel导入连续性内部资料
     * @Return : java.lang.StringBuilder
     * @Author : kzl
     * @Date : 2020/8/15 15:23
     */
//    private StringBuilder importContinuityInformation(StringBuilder message, Sheet sheet) {
//        /**key的值为期刊名称+期刊号，用来判断excel数据是否重复**/
//        HashMap<String, String> map = new HashMap<>();
//        List<FruitDTO> fruitDTOList = new ArrayList<>();
//        SimpleDateFormat ft = new SimpleDateFormat("yyyy年MM月dd日");
//        // 获取每行中的字段,过滤首行说明和第二行字段信息
//        for (int i = 2; i <= sheet.getLastRowNum(); i++) {
//            boolean[] flag = {true};
//            FruitDTO fruitDTO = new FruitDTO();
//            fruitDTO.setOrgId(OrgAccountHelper.getOrgId());
//            fruitDTO.setType(ComConstant.FruitType.ContinuityInformation);
//            fruitDTO.setIsSpecialSub("1");
//            Row row = sheet.getRow(i);
//            if (isRowEmpty(row)) {
//                continue;
//            }
//            // 获取刊物类型
//            if (null == row.getCell(0)) {
//                message.append("第" + (i + 1) + "行的刊物类型不能为空;\n");
//                flag[0] = false;
//            } else {
//                //根据刊物类型名称获取对应的值
//                fruitDTO.setPublicationType(ComConstant.descValueMapCons.get("PublicationType").get(row.getCell(0).getStringCellValue().trim()));
//            }
//
//            // 获取刊物名称
//            if (null == row.getCell(1)) {
//                message.append("第" + (i + 1) + "行的刊物名称不能为空;\n");
//                flag[0] = false;
//            } else {
//                fruitDTO.setName(row.getCell(1).getStringCellValue().trim());
//            }
//
//            // 获取主办单位
//            if (null != row.getCell(2)) {
//                fruitDTO.setOrganizer(row.getCell(2).getStringCellValue().trim());
//            }
//
//            // 获取主管单位
//            if (null == row.getCell(3)) {
//                message.append("第" + (i + 1) + "行的主管单位不能为空;\n");
//                flag[0] = false;
//            } else {
//                fruitDTO.setCompetentUnit(row.getCell(3).getStringCellValue().trim());
//            }
//
//            // 获取主编
//            if (null == row.getCell(4)) {
//                message.append("第" + (i + 1) + "行的主编不能为空;\n");
//                flag[0] = false;
//            } else {
//                fruitDTO.setChiefEditor(row.getCell(4).getStringCellValue().trim());
//            }
//
//            // 获取创办日期
//            if (null != row.getCell(5)) {
//                Cell cell = row.getCell(5);
//                if (CellType.NUMERIC.getCode() == cell.getCellType()) {
//                    fruitDTO.setCreateDate(cell.getDateCellValue());
//                } else {
//                    try {
//                        fruitDTO.setCreateDate(ft.parse(cell.getStringCellValue()));
//                    } catch (ParseException e) {
//                        e.printStackTrace();
//                        message.append("第" + (i + 1) + "行的创办日期格式不正确;\n");
//                        flag[0] = false;
//                    }
//                }
//            }
//
//            // 获取期号
//            if (null == row.getCell(6)) {
//                message.append("第" + (i + 1) + "行的期号不能为空;\n");
//                flag[0] = false;
//            } else {
//                fruitDTO.setIssueNumber(row.getCell(6).getStringCellValue().trim());
//            }
//
//            int munber = fruitRepository.findExistsByNameAndID(fruitDTO.getName(), fruitDTO.getType(), fruitDTO.getOrgId(), null, fruitDTO.getIssueNumber());
//            if (munber > 0) {
//                message.append("第" + (i + 1) + "行的期刊名称和期号在系统里面已经重复，不需要导入;\n");
//                flag[0] = false;
//            }
//            if (map.containsKey(fruitDTO.getName() + fruitDTO.getIssueNumber())) {
//                message.append("第" + (i + 1) + "行的期刊名称和期号重复;\n");
//                flag[0] = false;
//            } else {
//                map.put(fruitDTO.getName() + fruitDTO.getIssueNumber(), fruitDTO.getName() + fruitDTO.getIssueNumber());
//            }
//
//            // 获取出版周期
//            if (null != row.getCell(7)) {
//                fruitDTO.setPubCycle(ComConstant.descValueMapCons.get("PubCycle").get(row.getCell(7).getStringCellValue().trim()));
//            }
//
//            /**
//             * 判断是否重复
//             */
//            if(this.importFruitIsExist(fruitDTO.getType(), fruitDTO)){
//                message.append("第" + (i + 1) + "行的成果数据跟已有成果列表中的数据重复,若仍需导入,请手动添加！;\n");
//                flag[0] = false;
//            }
//            if (flag[0]) {
//                fruitDTOList.add(fruitDTO);
//            }
//
//        }
//        if(!CollectionUtils.isEmpty(fruitDTOList)){
//            this.saveFruitAndOrgRel(fruitDTOList);
//        }
//        return message;
//    }

    /**
     * @param message
     * @param sheet
     * @ClassName FruitServiceImpi
     * @Description : 通过excel导入内参
     * @Return : java.lang.StringBuilder
     * @Author : kzl
     * @Date : 2020/8/15 15:24
     */
    private void internalReferenceReportInformation(StringBuilder message, Sheet sheet) {
        //判断模版是不是新模版
        Row towRow = sheet.getRow(1);
//        if(!("途径部门").equals(towRow.getCell(9).getStringCellValue())){
//            message.append("检测到导入数据模版未更新（没有'途径部门'这一列），请更新新模板后再试！");
//            return;
//        }

        /**key的值为内参名称，用来判断excel数据是否重复**/
        HashMap<String, FruitDTO> map = new HashMap<>();
        /**key的值为报告题名+作者名称，用来判断excel数据是否重复，保存报告对应的作者信息**/
        HashMap<String, FruitAuthorPO> authorMap = new HashMap<>();
        /**key的值为报告题名+报送信息，用来判断报送数据是否重复，保存报送信息**/
        HashMap<String, FruitSubPO> subMap = new HashMap<>();
        List<FruitDTO> fruitDTOList = new ArrayList<>();
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        // 是否全部格式正确数量
        int allRows = sheet.getLastRowNum() - 1;
        // 已有格式正确数量
        int havedTrueRows = 0;
        // 获取每行中的字段,过滤首行说明和第二行字段信息
        for (int i = 2; i <= sheet.getLastRowNum(); i++) {
            boolean[] flag = {true};
            FruitDTO fruitDTO = new FruitDTO();
            fruitDTO.setIsPublic("0");
            fruitDTO.setOrgId(OrgAccountHelper.getOrgId());
            fruitDTO.setType(ComConstant.FruitType.InternalReferenceReport);
            fruitDTO.setIsSpecialSub("1");
            Row row = sheet.getRow(i);
            if (isRowEmpty(row)) {
                allRows -= 1;
                continue;
            }
            // 获取选题来源
            this.setCompleteMethod(fruitDTO, message, flag, i, row.getCell(0), "选题来源");
            // 获取内参题名
            this.setName(fruitDTO, message, flag, i, row.getCell(1), "内参题名");
            // 获取作者+单位
            fruitDTO = setAuthorOrg(fruitDTO, message, flag, i, row.getCell(2), row.getCell(3), true, map, authorMap);
//            // 获取关键词
//            this.setKeyword(fruitDTO, row.getCell(4));
            // 获取完成时间
            this.setPubTime(fruitDTO, message, flag, i, row.getCell(4), "完成日期");
            // 报送采用
            fruitDTO = this.setSubAndAdopt(fruitDTO, message, flag, i,
                    row.getCell(5), row.getCell(6),
                    row.getCell(7), row.getCell(8)
            );
            // 批示
            fruitDTO = this.setLeader(fruitDTO, message, flag, i,
                        row.getCell(9), row.getCell(10),
                        row.getCell(11), row.getCell(12),
                        row.getCell(13), row.getCell(14)
                );

            // 判断是否重复
//            if(this.importFruitIsExist(fruitDTO.getType(), fruitDTO)){
//                message.append("第" + (i + 1) + "行的成果数据跟已有成果列表中的数据重复,若仍需导入,请在列表中手动修改！;\n");
//                flag[0] = false;
//            }
            havedTrueRows++;
            //将成果存入Map
            map.put(fruitDTO.getName(), fruitDTO);
        }

        //如果全部正确
        if(allRows == havedTrueRows){
            for (String key : map.keySet()) {
                fruitDTOList.add(map.get(key));
            }
            if(!CollectionUtils.isEmpty(fruitDTOList)){
                this.saveFruitAndOrgRel(fruitDTOList);
            }
        }
    }


    /**
     * @param message
     * @param sheet
     * @ClassName FruitServiceImpi
     * @Description : 通过excel导入报告
     * @Return : java.lang.StringBuilder
     * @Author : kzl
     * @Date : 2020/8/15 15:23
     */
    private void reportInformation(StringBuilder message, Sheet sheet) {
        /**key的值为报告题名，用来保存成果信息**/
        HashMap<String, FruitDTO> map = new HashMap<>();
        /**key的值为报告题名+作者名称，用来判断excel数据是否重复，保存报告对应的作者信息**/
        HashMap<String, FruitAuthorPO> authorMap = new HashMap<>();
        List<FruitDTO> fruitDTOList = new ArrayList<>();
        // 是否全部格式正确数量
        int allRows = sheet.getLastRowNum() - 1;
        // 已有格式正确数量
        int havedTrueRows = 0;
        // 获取每行中的字段,过滤首行说明和第二行字段信息
        for (int i = 2; i <= sheet.getLastRowNum(); i++) {
            Row row = sheet.getRow(i);

            if (isRowEmpty(row)) {
                allRows -=1 ;
                continue;
            }
            boolean[] flag = {true};
            FruitDTO fruitDTO = new FruitDTO();
            fruitDTO.setIsPublic("0");
            fruitDTO.setOrgId(OrgAccountHelper.getOrgId());
            fruitDTO.setType(ComConstant.FruitType.REPORT);
            fruitDTO.setIsSpecialSub("1");

            // 获取报告类型
            this.setReportType(fruitDTO, message, flag, i, row.getCell(0));
            // 获取报告题名
            this.setName(fruitDTO, message, flag, i, row.getCell(1), "报告题名");
            // 获取作者+单位
            fruitDTO = setAuthorOrg(fruitDTO, message, flag, i, row.getCell(2), row.getCell(3), true, map, authorMap);
            // 获取完成时间
            this.setCompletionTime(fruitDTO, message, flag, i, row.getCell(4), "完成日期");
            // 获取发布时间
            this.setPubTime(fruitDTO, message, flag, i, row.getCell(5), "发布日期");
            // 获取关键词
            this.setKeyword(fruitDTO, row.getCell(6));
            // 获取摘要
            this.setSummary(fruitDTO, row.getCell(7));
            // 获取刊登情况
            this.setPublicationLevel(fruitDTO, message, flag, i, row.getCell(8), "刊登情况");
            // 获取名称和期数
            this.setJournalName(fruitDTO, row.getCell(9));
            // 获取主办单位
            this.setOrganizer(fruitDTO, row.getCell(10));

            //批示
            this.setLeader(fruitDTO, message, flag, i,
                    row.getCell(11), row.getCell(12),
                    row.getCell(13), row.getCell(14),
                    row.getCell(15), row.getCell(16)
            );
            //判断是否重复
//            if(this.importFruitIsExist(fruitDTO.getType(), fruitDTO)){
//                message.append("第" + (i + 1) + "行的成果数据跟已有成果列表中的数据重复,若仍需导入,请手动添加！;\n");
//                flag[0] = false;
//            }
            if (flag[0]) {
                havedTrueRows++;
                /**将成果存入入Map**/
                map.put(fruitDTO.getName(), fruitDTO);
            }
        }
        //如果全部正确
        if(allRows == havedTrueRows){
            for (String key : map.keySet()) {
                fruitDTOList.add(map.get(key));
            }
            if(!CollectionUtils.isEmpty(fruitDTOList)){
                this.saveFruitAndOrgRel(fruitDTOList);
            }
        }
    }


    /**
     * @param message
     * @param sheet
     * @ClassName FruitServiceImpi
     * @Description : 通过excel导入政策咨询
     * @Return : java.lang.StringBuilder
     * @Author : kzl
     * @Date : 2020/8/15 15:23
     */
//    private StringBuilder policyAdviceInformation(StringBuilder message, Sheet sheet) {
//        /**key的值为报告题名，用来保存成果信息**/
//        HashMap<String, FruitDTO> map = new HashMap<>();
//        /**key的值为报告题名+作者名称，用来判断excel数据是否重复，保存报告对应的作者信息**/
//        HashMap<String, FruitAuthorPO> authorMap = new HashMap<>();
//        List<FruitDTO> fruitDTOList = new ArrayList<>();
//        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
//        // 是否全部格式正确数量
//        int allRows = sheet.getLastRowNum() - 1;
//        // 已有格式正确数量
//        int havedTrueRows = 0;
//        // 获取每行中的字段,过滤首行说明和第二行字段信息
//        for (int i = 2; i <= sheet.getLastRowNum(); i++) {
//            boolean[] flag = {true};
//            FruitDTO fruitDTO = new FruitDTO();
//            fruitDTO.setIsPublic("0");
//            fruitDTO.setOrgId(OrgAccountHelper.getOrgId());
//            fruitDTO.setType(ComConstant.FruitType.PolicyAdvice);
//            fruitDTO.setIsSpecialSub("1");
//            Row row = sheet.getRow(i);
//            if (isRowEmpty(row)) {
//                allRows -=1 ;
//                continue;
//            }
//            Cell cell;
//            // 获取文稿名称
//            cell = row.getCell(0);
//            if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的文稿名称不能为空;\n")){
//                fruitDTO.setName(row.getCell(0).getStringCellValue().trim());
//            }
//            int munber = fruitRepository.findExistsByNameAndID(fruitDTO.getName(), fruitDTO.getType(), fruitDTO.getOrgId(), null, null);
//            if (munber > 0) {
//                message.append("第" + (i + 1) + "行的文稿名称在系统里面已经存在，不需要导入;\n");
//                flag[0] = false;
//            }
//
//            // 获取文稿类型
//            cell = row.getCell(1);
//            if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的文稿类型不能为空;\n")){
//                //根据文稿类型获取对应的值
//                List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("policyType", cell.getStringCellValue().trim());
//                if (sysDicts.size() > 0) {
//                    fruitDTO.setPolicyType(sysDicts.get(0).getDvalue());
//                } else {
//                    message.append("第" + (i + 1) + "行的文稿类型填写错误;\n");
//                    flag[0] = false;
//                }
//
//            }
//
//            //获取起草时间
//            cell = row.getCell(2);
//            if (null != cell) {
//                if (CellType.NUMERIC.getCode() == cell.getCellType()) {
//                    fruitDTO.setDraftTime(cell.getDateCellValue());
//                } else {
//                    try {
//                        fruitDTO.setDraftTime(ft.parse(cell.getStringCellValue()));
//                    } catch (ParseException e) {
//                        e.printStackTrace();
//                        message.append("第" + (i + 1) + "行的起草时间格式不正确;\n");
//                        flag[0] = false;
//                    }
//                }
//            }
//
//            FruitAuthorPO fruitAuthorPO = new FruitAuthorPO();
//            // 获取作者
//            cell = row.getCell(3);
//            if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的作者不能为空;\n")){
//                /**同一个excel里，报告+作者重复，则默认为重复数据，否则相同提名报告，按照execl顺序计算作者排名**/
//                if (authorMap.containsKey(fruitDTO.getName() + RegularExpressionUtil.filterSpace(cell.getStringCellValue()))) {
//                    message.append("第" + (i + 1) + "行的报告提名和作者在excel表格重复!;\n");
//                    flag[0] = false;
//                } else {
//                    fruitAuthorPO.setAuthor(RegularExpressionUtil.filterSpace(row.getCell(3).getStringCellValue()));
//                    fruitAuthorPO.setOrgId(OrgAccountHelper.getOrgId());
//                    //组装查询查询条件，查询该机构下的同名专家或者临时专家信息
//                    fruitDTO = getFruitDTO(map, fruitDTO, fruitAuthorPO);
//                }
//            }
//
//            // 获取单位
//            cell = row.getCell(4);
//            if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的单位不能为空;\n")){
//                String[] ss = cell.getStringCellValue().split("\n");
//                setAuthorOrg(authorMap, fruitDTO, fruitAuthorPO, ss);
//            }
//
//            // 获取委托方名称
//            cell = row.getCell(5);
//            if (null != cell) {
//                fruitDTO.setClient(cell.getStringCellValue().trim());
//            }
//
//            // 获取委托方类型
//            cell = row.getCell(6);
//            if (null != cell) {
//                //根据刊物类型名称获取对应的值
//                List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("clientType", cell.getStringCellValue().trim());
//                if (sysDicts.size() > 0) {
//                    fruitDTO.setClientType(sysDicts.get(0).getDvalue());
//                } else {
//                    message.append("第" + (i + 1) + "行的委托方类型填写错误;\n");
//                    flag[0] = false;
//                }
//            }
//
//            // 获取委托方等级
//            cell = row.getCell(7);
//            if (null != cell) {
//                //根据刊物类型名称获取对应的值
//                List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("clientLevel", cell.getStringCellValue().trim());
//                if (sysDicts.size() > 0) {
//                    fruitDTO.setClientLevel(sysDicts.get(0).getDvalue());
//                } else {
//                    message.append("第" + (i + 1) + "行的委托方等级填写错误;\n");
//                    flag[0] = false;
//                }
//            }
//            /**
//             * 判断是否重复
//             */
//            if(this.importFruitIsExist(fruitDTO.getType(), fruitDTO)){
//                message.append("第" + (i + 1) + "行的成果数据跟已有成果列表中的数据重复,若仍需导入,请手动添加！;\n");
//                flag[0] = false;
//            }
//            if (flag[0]) {
//                havedTrueRows++;
//                /**将成果存入入Map**/
//                map.put(fruitDTO.getName(), fruitDTO);
//            }
//        }
//        //如果全部正确
//        if(allRows == havedTrueRows){
//            for (String key : map.keySet()) {
//                fruitDTOList.add(map.get(key));
//            }
//            if(!CollectionUtils.isEmpty(fruitDTOList)){
//                this.saveFruitAndOrgRel(fruitDTOList);
//            }
//        }
//        return message;
//    }


    /**
     * @param message
     * @param sheet
     * @ClassName FruitServiceImpi
     * @Description : 通过excel导入活动参与成果
     * @Return : java.lang.StringBuilder
     * @Author : kzl
     * @Date : 2020/8/15 15:23
     */
    private void activityInformation(StringBuilder message, Sheet sheet, String activityProdType) {
        /**key的值为报告题名，用来保存成果信息**/
        HashMap<String, FruitDTO> map = new HashMap<>();
        /**key的值为报告题名+作者名称，用来判断excel数据是否重复，保存报告对应的作者信息**/
        HashMap<String, FruitAuthorPO> authorMap = new HashMap<>();
        List<FruitDTO> fruitDTOList = new ArrayList<>();
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        // 是否全部格式正确数量
        int allRows = sheet.getLastRowNum() - 1;
        // 已有格式正确数量
        int havedTrueRows = 0;
        // 获取每行中的字段,过滤首行说明和第二行字段信息
        for (int i = 2; i <= sheet.getLastRowNum(); i++) {
            boolean[] flag = {true};
            FruitDTO fruitDTO = new FruitDTO();
            fruitDTO.setIsPublic("0");
            fruitDTO.setOrgId(OrgAccountHelper.getOrgId());
            fruitDTO.setType(ComConstant.FruitType.PolicyAdvice);
            fruitDTO.setIsSpecialSub("1");
            fruitDTO.setActivityProdType(activityProdType);
            Row row = sheet.getRow(i);
            if (isRowEmpty(row)) {
                allRows -=1 ;
                continue;
            }
            Cell cell;
            //----------出席会议-------------
            if(ComConstant.FruitType.MEETING.equals(activityProdType)){
                // 获取活动名称
                this.setName(fruitDTO, message, flag, i, row.getCell(0), "活动名称");
                //获取开始时间
                this.setPubTime(fruitDTO, message, flag, i, row.getCell(1), "时间");
                // 获取会议类型
                this.setMeetingType(fruitDTO, message, flag, i, row.getCell(2));
                // 获取会议级别
                this.setMeetingLevel(fruitDTO, message, flag, i, row.getCell(3), "会议级别");
//                this.setAwardsLevel(fruitDTO, message, flag, i, row.getCell(3), "会议级别");
                // 获取主办单位
                this.setOrganizer(fruitDTO, row.getCell(4));
                // 获取作者+单位
                fruitDTO = this.setZyExpertOrg(fruitDTO, message, flag, i,
                        row.getCell(5), row.getCell(6), row.getCell(7), row.getCell(8), row.getCell(9),
                        map, authorMap);

                // 获取备注--输出成果（含预计输出成果）
                this.setRemark(fruitDTO, row.getCell(10));
                // 获取协办单位--除中国移动外其他参与单位
                this.setCoorganizer(fruitDTO, row.getCell(11));

//                // 获取英文名称
//                this.setEnglishName(fruitDTO, row.getCell(2));
//                // 获取承办单位
//                this.setUndertaker(fruitDTO, row.getCell(4));
//                // 获取协办单位
//                this.setCoorganizer(fruitDTO, row.getCell(5));
//                // 获取合作单位
//                this.setCooperator(fruitDTO, row.getCell(6));
//                // 获取会议主题
//                this.setTheme(fruitDTO, message, flag, i, row.getCell(7));
//                // 获取举办地点
//                this.setPubPlace(fruitDTO, message, flag, i, row.getCell(8));
//                // 获取会议天数
//                this.setMeetingDays(fruitDTO, row.getCell(11));
//                // 获取备注
//                this.setRemark(fruitDTO, row.getCell(16));

            }else if(ComConstant.FruitType.RECEIVE_VISITORS.equals(activityProdType)){
                //----------接待来访-------------
                // 获取访问类型
                this.setVisitType(fruitDTO, message, flag, i, row.getCell(0), "访问类型");
                // 获取来访主题
                this.setName(fruitDTO, message, flag, i, row.getCell(1), "考察调研主题");
                // 获取组织单位
                this.setOrganizer(fruitDTO, message, flag, i, row.getCell(2), "组织单位");
                // 获取关键词
                this.setKeyword(fruitDTO, row.getCell(3));
                // 获取来访日期
                this.setPubTime(fruitDTO, message, flag, i, row.getCell(4), "来访日期");
                // 获取来访级别
                this.setAwardsLevel(fruitDTO, message, flag, i, row.getCell(5), "来访级别");
                // 获取作者+单位
                fruitDTO = setAuthorOrg(fruitDTO, message, flag, i, row.getCell(6), row.getCell(7), false, map, authorMap);
                // 获取摘要
                this.setSummary(fruitDTO, row.getCell(8));
                // 获取来访内容
                this.setField(fruitDTO, row.getCell(9));
                // 获取备注
                this.setRemark(fruitDTO, row.getCell(10));

            }else if(ComConstant.FruitType.SURVEY.equals(activityProdType)) {
                //----------考察调研-------------
                // 获取访问类型
                this.setVisitType(fruitDTO, message, flag, i, row.getCell(0), "访问类型");
                // 获取考察调研主题
                this.setName(fruitDTO, message, flag, i, row.getCell(1), "考察调研主题");
                // 获取组织单位
                this.setOrganizer(fruitDTO, message, flag, i, row.getCell(2), "组织单位");
                // 获取接待单位
                this.setUndertaker(fruitDTO, row.getCell(3));
                // 获取考察调研时间
                this.setPubTime(fruitDTO, message, flag, i, row.getCell(4), "考察调研时间");
                // 获取考察调研天数
                this.setMeetingDays(fruitDTO, message, flag, i, row.getCell(5), "考察调研天数");
                // 获取考察调研级别
                this.setAwardsLevel(fruitDTO, message, flag, i, row.getCell(6), "考察调研级别");
                // 获取考察调研负责人
                this.setChiefEditor(fruitDTO, row.getCell(7));
                // 获取考察调研内容
                this.setSummary(fruitDTO, row.getCell(8));
                // 获取考察调研对象
                this.setPubObject(fruitDTO, row.getCell(9));
                // 获取备注
                this.setRemark(fruitDTO, row.getCell(10));

            }else if(ComConstant.FruitType.TRAINING.equals(activityProdType)) {
                //----------授课培训-------------
                // 获取培训名称
                this.setName(fruitDTO, message, flag, i, row.getCell(0), "培训名称");
                // 获取培训主题
                this.setTheme(fruitDTO, row.getCell(1));
                // 获取开始时间
                this.setPubTime(fruitDTO, message, flag, i, row.getCell(2), "开始时间");
                // 获取授课培训天数
                this.setMeetingDays(fruitDTO, row.getCell(3));
                // 获取主办单位
                this.setOrganizer(fruitDTO, message, flag, i, row.getCell(4), "主办单位");
                // 获取承办单位
                this.setUndertaker(fruitDTO, row.getCell(5));
                // 获取协办单位
                this.setCoorganizer(fruitDTO, row.getCell(6));
                // 获取合作单位
                this.setCooperator(fruitDTO, row.getCell(7));
                // 获取作者+单位
                fruitDTO = setAuthorOrg(fruitDTO, message, flag, i, row.getCell(8), row.getCell(9), false, map, authorMap);
                // 获取培训对象
                this.setPubObject(fruitDTO, row.getCell(10));
                // 获取培训级别
                this.setAwardsLevel(fruitDTO, message, flag, i, row.getCell(11), "培训级别");
                // 获取委托单位
                this.setClient(fruitDTO, row.getCell(12));
                // 获取参与人数
                this.setReadNumber(fruitDTO, row.getCell(13));
                // 获取培训地点
                this.setPubPlace(fruitDTO, row.getCell(14));
                // 获取主要内容
                this.setSummary(fruitDTO, row.getCell(15));
                // 获取备注
                this.setRemark(fruitDTO, row.getCell(16));
            }
//            // 判断是否重复
//            if(this.importFruitIsExist(fruitDTO.getType(), fruitDTO)){
//                message.append("第" + (i + 1) + "行的成果数据跟已有成果列表中的数据重复,若仍需导入,请手动添加！;\n");
//                flag[0] = false;
//            }
            if (flag[0]) {
                havedTrueRows++;
                //将成果存入入Map
                map.put(fruitDTO.getName(), fruitDTO);
            }
        }
        //如果全部正确
        if(allRows == havedTrueRows){
            for (String key : map.keySet()) {
                fruitDTOList.add(map.get(key));
            }
            if(!CollectionUtils.isEmpty(fruitDTOList)){
                this.saveFruitAndOrgRel(fruitDTOList);
            }
        }
    }


    /**
     * @param message
     * @param sheet
     * @ClassName FruitServiceImpi
     * @Description : 通过excel导入媒体成果
     * @Return : java.lang.StringBuilder
     * @Author : kzl
     * @Date : 2020/8/15 15:23
     */
    private void newspaperORNetworkInformation(StringBuilder message, Sheet sheet, String activityProdType) {
        /**key的值为报告题名，用来保存成果信息**/
        HashMap<String, FruitDTO> map = new HashMap<>();
        /**key的值为报告题名+作者名称，用来判断excel数据是否重复，保存报告对应的作者信息**/
        HashMap<String, FruitAuthorPO> authorMap = new HashMap<>();
        List<FruitDTO> fruitDTOList = new ArrayList<>();
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        // 是否全部格式正确数量
        int allRows = sheet.getLastRowNum() - 1;
        // 已有格式正确数量
        int havedTrueRows = 0;
        // 获取每行中的字段,过滤首行说明和第二行字段信息
        for (int i = 2; i <= sheet.getLastRowNum(); i++) {
            boolean[] flag = {true};
            FruitDTO fruitDTO = new FruitDTO();
            fruitDTO.setIsPublic("0");
            fruitDTO.setOrgId(OrgAccountHelper.getOrgId());
            fruitDTO.setType(ComConstant.FruitType.NewspaperORNetwork);
            fruitDTO.setIsSpecialSub("1");
            fruitDTO.setActivityProdType(activityProdType);
            Row row = sheet.getRow(i);
            if (isRowEmpty(row)) {
                allRows -=1 ;
                continue;
            }
            //----------媒体发文-------------
            if(ComConstant.FruitType.MEDIA_PUBLISHED_ARTICLES.equals(activityProdType)){
                // 获取文章题名
                this.setName(fruitDTO, message, flag, i, row.getCell(0), "文章题名");
                // 获取作者+单位
                fruitDTO = setAuthorOrg(fruitDTO, message, flag, i, row.getCell(1), row.getCell(2), true, map, authorMap);
                // 获取刊载媒体
                this.setJournalName(fruitDTO, row.getCell(3));
                // 获取媒体级别
                this.setPublicationLevel(fruitDTO, message, flag, i, row.getCell(4), "媒体级别");
                // 获取媒体类别
                this.setMediaType(fruitDTO, message, flag, i, row.getCell(5), "媒体类型");
                // 获取发表日期
                this.setPubTime(fruitDTO, message, flag, i, row.getCell(6), "发表日期");
                // 是否以外文发布或在国际场合发布
                this.setIsForeign(fruitDTO, message, flag, i, row.getCell(7), "是否以外文发布或在国际场合发布");
                // 获取阅读量
//                this.setReadNumber(fruitDTO, row.getCell(7));
                // 获取链接
                this.setLinkUrl(fruitDTO,  message, flag, i, row.getCell(8), "报道链接");
                // 获取关键词
//                this.setKeyword(fruitDTO, row.getCell(9));
                // 获取摘要
//                this.setSummary(fruitDTO, row.getCell(10));
                // 获取政策研究领域
//                this.setField(fruitDTO, row.getCell(11));

            }else if(ComConstant.FruitType.MEDIA_INTERVIEW.equals(activityProdType)){
                //----------接受采访-------------
                // 获取采访机构分类
                this.setMediaType(fruitDTO, message, flag, i, row.getCell(0), "采访机构分类");
                // 获取采访主题
                this.setName(fruitDTO, message, flag, i, row.getCell(1), "采访主题");
                // 获取采访媒体
                this.setOrganizer(fruitDTO, message, flag, i, row.getCell(2), "采访媒体");
                // 获取采访级别
                this.setAwardsLevel(fruitDTO, message, flag, i, row.getCell(3), "采访级别");
                // 获取采访时间
                this.setPubTime(fruitDTO, message, flag, i, row.getCell(4), "采访时间");
                // 获取作者+单位
                fruitDTO = this.setExpertOrg(fruitDTO, message, flag, i, row.getCell(5), row.getCell(7), row.getCell(8), row.getCell(6), map, authorMap);
                // 获取备注
                this.setRemark(fruitDTO, row.getCell(9));

            }
            // 判断是否重复
//            if(this.importFruitIsExist(fruitDTO.getType(), fruitDTO)){
//                message.append("第" + (i + 1) + "行的成果数据跟已有成果列表中的数据重复,若仍需导入,请手动添加！;\n");
//                flag[0] = false;
//            }
            if (flag[0]) {
                havedTrueRows++;
                //将成果存入入Map
                map.put(fruitDTO.getName(), fruitDTO);
            }
        }
        //如果全部正确
        if(allRows == havedTrueRows){
            for (String key : map.keySet()) {
                fruitDTOList.add(map.get(key));
            }
            if(!CollectionUtils.isEmpty(fruitDTOList)){
                this.saveFruitAndOrgRel(fruitDTOList);
            }
        }
    }


    /**
     * @param message
     * @param sheet
     * @ClassName FruitServiceImpi
     * @Description : 通过excel导入论文
     * @Return : java.lang.StringBuilder
     * @Author : kzl
     * @Date : 2020/8/15 15:23
     */
    private void paperInformation(StringBuilder message, Sheet sheet) {
        /**key的值为报告题名，用来保存成果信息**/
        HashMap<String, FruitDTO> map = new HashMap<>();
        /**key的值为报告题名+作者名称，用来判断excel数据是否重复，保存报告对应的作者信息**/
        HashMap<String, FruitAuthorPO> authorMap = new HashMap<>();
        List<FruitDTO> fruitDTOList = new ArrayList<>();
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        // 是否全部格式正确数量
        int allRows = sheet.getLastRowNum() - 1;
        // 已有格式正确数量
        int havedTrueRows = 0;
        //获取每行中的字段,过滤首行说明和第二行字段信息
        for (int i = 2; i <= sheet.getLastRowNum(); i++) {
            boolean[] flag = {true};
            FruitDTO fruitDTO = new FruitDTO();
            fruitDTO.setIsPublic("0");
            fruitDTO.setOrgId(OrgAccountHelper.getOrgId());
            fruitDTO.setType(ComConstant.FruitType.Paper);
            fruitDTO.setIsSpecialSub("1");
            Row row = sheet.getRow(i);
            if (isRowEmpty(row)) {
                allRows -=1 ;
                continue;
            }
            // 获取论文类型
            this.setPaperType(fruitDTO, message, flag, i, row.getCell(0), "论文类型");
            // 获取篇名
            this.setName(fruitDTO, message, flag, i, row.getCell(1), "篇名");
            // 获取作者+单位
            fruitDTO = setAuthorOrg(fruitDTO, message, flag, i, row.getCell(2), row.getCell(3), true, map, authorMap);
            // 获取期刊名字
            this.setJournalName(fruitDTO, row.getCell(4));
            // 卷（期）次/版次
            this.setIssueNumber(fruitDTO, row.getCell(5));
            //期刊类别
            this.setJournalType(fruitDTO, message, flag, i, row.getCell(6), "期刊类别");
            //获取发表时间
            this.setPubTime(fruitDTO, message, flag, i, row.getCell(7), "发表日期");
            //获取关键词
            this.setKeyword(fruitDTO, row.getCell(8));
            //获取摘要
            this.setSummary(fruitDTO, row.getCell(9));

            // 判断是否重复
//            if(this.importFruitIsExist(fruitDTO.getType(), fruitDTO)){
//                message.append("第" + (i + 1) + "行的成果数据跟已有成果列表中的数据重复,若仍需导入,请手动添加！;\n");
//                flag[0] = false;
//            }
            if (flag[0]) {
                havedTrueRows++;
                //将成果存入入Map
                map.put(fruitDTO.getName(), fruitDTO);
            }
        }
        //如果全部正确
        if(allRows == havedTrueRows){
            for (String key : map.keySet()) {
                fruitDTOList.add(map.get(key));
            }
            if(!CollectionUtils.isEmpty(fruitDTOList)){
                this.saveFruitAndOrgRel(fruitDTOList);
            }
        }
    }


    /**
     * @param message
     * @param sheet
     * @ClassName FruitServiceImpi
     * @Description : 通过excel导入图书
     * @Return : java.lang.StringBuilder
     * @Author : kzl
     * @Date : 2020/8/15 15:23
     */
    private StringBuilder bookInformation(StringBuilder message, Sheet sheet) {
        /**key的值为报告题名，用来保存成果信息**/
        HashMap<String, FruitDTO> map = new HashMap<>();
        /**key的值为报告题名+作者名称，用来判断excel数据是否重复，保存报告对应的作者信息**/
        HashMap<String, FruitAuthorPO> authorMap = new HashMap<>();
        List<FruitDTO> fruitDTOList = new ArrayList<>();
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        // 是否全部格式正确数量
        int allRows = sheet.getLastRowNum() - 1;
        // 已有格式正确数量
        int havedTrueRows = 0;
        // 获取每行中的字段,过滤首行说明和第二行字段信息
        for (int i = 2; i <= sheet.getLastRowNum(); i++) {
            boolean[] flag = {true};
            FruitDTO fruitDTO = new FruitDTO();
            fruitDTO.setIsPublic("0");
            fruitDTO.setOrgId(OrgAccountHelper.getOrgId());
            fruitDTO.setType(ComConstant.FruitType.BOOK);
            fruitDTO.setIsSpecialSub("1");
            Row row = sheet.getRow(i);
            if (isRowEmpty(row)) {
                allRows -=1 ;
                continue;
            }
            // 获取图书类型
            this.setBookType(fruitDTO, message, flag, i, row.getCell(0), "图书类型");
            // 获取中文书名
            this.setName(fruitDTO, message, flag, i, row.getCell(1), "中文书名");
            // 获取ISBN
            this.setIsbn(fruitDTO, row.getCell(2));
            // 出版社
            this.setPress(fruitDTO, row.getCell(3));
            // 获取关键词
            this.setKeyword(fruitDTO, row.getCell(4));
            // 获取版次
            this.setEdition(fruitDTO, row.getCell(5));
            // 获取出版时间
            this.setPubTime(fruitDTO, message, flag, i, row.getCell(6), "出版时间");
            // 获取作者+单位
            fruitDTO = setAuthorOrg(fruitDTO, message, flag, i, row.getCell(7), row.getCell(8), true, map, authorMap);
            // 著作方式
            this.setWriteType(fruitDTO, message, flag, i, row.getCell(9), "著作方式");

            // 判断是否重复
//            if(this.importFruitIsExist(fruitDTO.getType(), fruitDTO)){
//                message.append("第" + (i + 1) + "行的成果数据跟已有成果列表中的数据重复,若仍需导入,请手动添加！;\n");
//                flag[0] = false;
//            }
            if (flag[0]) {
                havedTrueRows++;
                // 将成果存入入Map
                map.put(fruitDTO.getName(), fruitDTO);
            }
        }
        //如果全部正确
        if(allRows == havedTrueRows){
            for (String key : map.keySet()) {
                fruitDTOList.add(map.get(key));
            }
            if(!CollectionUtils.isEmpty(fruitDTOList)){
                this.saveFruitAndOrgRel(fruitDTOList);
            }
        }
        return message;
    }


    /**
     * @param message
     * @param sheet
     * @ClassName FruitServiceImpi
     * @Description : 通过excel导入荣誉信息
     * @Return : java.lang.StringBuilder
     * @Author : kzl
     * @Date : 2020/8/15 15:23
     */
    private void priceInformation(StringBuilder message, Sheet sheet) {
        /**key的值为报告题名，用来保存成果信息**/
        HashMap<String, FruitDTO> map = new HashMap<>();
        /**key的值为报告题名+奖项名称+作者，用来判断excel数据是否重复，保存报告对应的作者信息**/
        HashMap<String, FruitAuthorPO> authorMap = new HashMap<>();
        List<FruitDTO> fruitDTOList = new ArrayList<>();
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        // 是否全部格式正确数量
        int allRows = sheet.getLastRowNum() - 1;
        // 已有格式正确数量
        int havedTrueRows = 0;
        // 获取每行中的字段,过滤首行说明和第二行字段信息
        for (int i = 2; i <= sheet.getLastRowNum(); i++) {
            boolean[] flag = {true};
            FruitDTO fruitDTO = new FruitDTO();
            fruitDTO.setIsPublic("0");
            fruitDTO.setOrgId(OrgAccountHelper.getOrgId());
            fruitDTO.setType(ComConstant.FruitType.PRICE);
            fruitDTO.setIsSpecialSub("1");
            Row row = sheet.getRow(i);
            if (isRowEmpty(row)) {
                allRows -=1 ;
                continue;
            }
            // 获取获奖作品
            this.setAwards(fruitDTO, row.getCell(0));
            // 获取获奖名称
            this.setName(fruitDTO, message, flag, i, row.getCell(1), "获奖名称");


            FruitAuthorPO fruitAuthorPO = new FruitAuthorPO();
            // 获取作者
            if (null == row.getCell(2)) {
                message.append("第" + (i + 1) + "行的作者不能为空;\n");
                flag[0] = false;
            } else {
                fruitAuthorPO.setAuthor(RegularExpressionUtil.filterSpace(row.getCell(2).getStringCellValue()));
                /**同一个excel里，文章题名+奖项+作者重复，则默认为重复数据，否则相同提名报告，按照execl顺序计算作者排名**/
                if (authorMap.containsKey(fruitDTO.getName() + fruitDTO.getAwards() + fruitAuthorPO.getAuthor())) {
                    message.append("第" + (i + 1) + "行的文章题名和作者在excel表格重复!;\n");
                    flag[0] = false;
                } else {
                    fruitAuthorPO.setAuthor(RegularExpressionUtil.filterSpace(row.getCell(2).getStringCellValue()));
                    setAuthor(fruitAuthorPO);
                    /**
                     * 判断作品名称+奖项在map是否存在，存在则获取对应的作者排名
                     *  存在则依次进行排名，否则为第一作者
                     * **/
                    if (map.containsKey(fruitDTO.getName() + fruitDTO.getAwards())) {
                        //查找成果对象
                        fruitDTO = map.get(fruitDTO.getName() + fruitDTO.getAwards());
                        fruitAuthorPO.setRanking(fruitDTO.getAuthorPOList().size() + 1);
                    } else {
                        fruitAuthorPO.setRanking(1);
                    }
                }
            }

            // 获取单位
            if (null == row.getCell(3)) {
                message.append("第" + (i + 1) + "行的单位不能为空;\n");
                flag[0] = false;
            } else {
                String[] ss = row.getCell(3).getStringCellValue().split("\n");
                for (int j = 1; j <= ss.length; j++) {
                    //设置作者单位
                    FruitAuthorOrgPO fruitAuthorOrgPO = new FruitAuthorOrgPO();
                    fruitAuthorOrgPO.setRanking(j);
                    fruitAuthorOrgPO.setName(ss[j - 1]);
                    fruitAuthorPO.getOrgPOList().add(fruitAuthorOrgPO);
                }
                fruitDTO.getAuthorPOList().add(fruitAuthorPO);
                /**将报告名称+作者名以key值存入authorMap**/
                authorMap.put(fruitDTO.getName() + fruitDTO.getAwards() + fruitAuthorPO.getAuthor(), fruitAuthorPO);
            }

            //获取颁奖单位
            this.setGrantUnit(fruitDTO, row.getCell(4));
            //获取主办单位
            this.setOrganizer(fruitDTO, row.getCell(5));
            //获取获奖时间
            this.setPubTime(fruitDTO, message, flag, i, row.getCell(6), "获奖时间");
            //获取奖项级别
            this.setAwardsLevel(fruitDTO, message, flag, i, row.getCell(7), "奖项级别");

            // 判断是否重复
//            if(this.importFruitIsExist(fruitDTO.getType(), fruitDTO)){
//                message.append("第" + (i + 1) + "行的成果数据跟已有成果列表中的数据重复,若仍需导入,请手动添加！;\n");
//                flag[0] = false;
//            }
            if (flag[0]) {
                havedTrueRows++;
                // 将成果存入入Map
                map.put(fruitDTO.getName() + fruitDTO.getAwards(), fruitDTO);
            }
        }
        //如果全部正确
        if(allRows == havedTrueRows){
            for (String key : map.keySet()) {
                fruitDTOList.add(map.get(key));
            }
            if(!CollectionUtils.isEmpty(fruitDTOList)){
                this.saveFruitAndOrgRel(fruitDTOList);
            }
        }
    }


    /**
     * @param message
     * @param sheet
     * @ClassName FruitServiceImpi
     * @Description : 通过excel导入荣誉信息
     * @Return : java.lang.StringBuilder
     * @Author : kzl
     * @Date : 2020/8/15 15:23
     */
    private StringBuilder otherInformation(StringBuilder message, Sheet sheet) {
        /**key的值为报告题名，用来保存成果信息**/
        HashMap<String, FruitDTO> map = new HashMap<>();
        /**key的值为报告题名+奖项名称+作者，用来判断excel数据是否重复，保存报告对应的作者信息**/
        HashMap<String, FruitAuthorPO> authorMap = new HashMap<>();
        List<FruitDTO> fruitDTOList = new ArrayList<>();
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        // 是否全部格式正确数量
        int allRows = sheet.getLastRowNum() - 1;
        // 已有格式正确数量
        int havedTrueRows = 0;
        // 获取每行中的字段,过滤首行说明和第二行字段信息
        for (int i = 2; i <= sheet.getLastRowNum(); i++) {
            boolean[] flag = {true};
            FruitDTO fruitDTO = new FruitDTO();
            fruitDTO.setIsPublic("0");
            fruitDTO.setOrgId(OrgAccountHelper.getOrgId());
            fruitDTO.setType(ComConstant.FruitType.PRICE);
            fruitDTO.setIsSpecialSub("1");
            Row row = sheet.getRow(i);
            if (isRowEmpty(row)) {
                allRows -=1 ;
                continue;
            }
            // 获取篇名
            if (null == row.getCell(0)) {
                message.append("第" + (i + 1) + "行的出版物名称不能为空;\n");
                flag[0] = false;
            } else {
                fruitDTO.setName(row.getCell(0).getStringCellValue().trim());
            }
            int munber = fruitRepository.findExistsByNameAndID(fruitDTO.getName(), fruitDTO.getType(), fruitDTO.getOrgId(), null, null);
            if (munber > 0) {
                message.append("第" + (i + 1) + "行的出版物名称在系统里面已经存在，不需要导入;\n");
                flag[0] = false;
            }

            // 获取出版周期
            if (null != row.getCell(1)) {
                //根据出版周期名称获取对应的值
                List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("pubCycle", row.getCell(1).getStringCellValue().trim());
                if (sysDicts.size() > 0) {
                    fruitDTO.setPubCycle(sysDicts.get(0).getDvalue());
                } else {
                    message.append("第" + (i + 1) + "行的出版周期填写错误;\n");
                    flag[0] = false;
                }
            }

            // 获取政策研究领域
            if (null != row.getCell(2)) {
                fruitDTO.setField(row.getCell(2).getStringCellValue().trim());
            }

            // 获取出版地
            if (null != row.getCell(3)) {
                fruitDTO.setPubPlace(row.getCell(3).getStringCellValue().trim());
            }

            // 获取出版社
            if (null != row.getCell(4)) {
                fruitDTO.setPress(row.getCell(4).getStringCellValue().trim());
            }

            //获取主办单位
            if (null != row.getCell(5)) {
                fruitDTO.setOrganizer(row.getCell(5).getStringCellValue().trim());
            }

            //获取ISSN/CN  去除-
            if (null != row.getCell(6)) {
                fruitDTO.setIsbn(row.getCell(6).getStringCellValue().trim().replaceAll("-", ""));
            }

            //获取是否公开
            if (null != row.getCell(7)) {
                if ("是".equals(row.getCell(7).getStringCellValue().trim())) {
                    fruitDTO.setIsOpen(true);
                } else {
                    fruitDTO.setIsOpen(false);
                }
            }

            //获取邮发代号
            if (null != row.getCell(8)) {
                fruitDTO.setPostalCode(row.getCell(8).getStringCellValue().trim());
            }

            //获取语种
            if (null != row.getCell(9)) {
                fruitDTO.setLanguages(row.getCell(9).getStringCellValue().trim());
            }

            //获取语种
            if (null != row.getCell(9)) {
                fruitDTO.setLanguages(row.getCell(9).getStringCellValue().trim());
            }

            //获取期刊网址
            if (null != row.getCell(10)) {
                fruitDTO.setWebsite(row.getCell(10).getStringCellValue().trim());
            }

            //获取开本
            if (null != row.getCell(11)) {
                fruitDTO.setBookSize(row.getCell(11).getStringCellValue().trim());
            }
            if (map.containsKey(fruitDTO.getName())) {
                message.append("第" + (i + 1) + "行的期刊名称重复;\n");
                flag[0] = false;
            }
            /**
             * 判断是否重复
             */
//            if(this.importFruitIsExist(fruitDTO.getType(), fruitDTO)){
//                message.append("第" + (i + 1) + "行的成果数据跟已有成果列表中的数据重复,若仍需导入,请手动添加！\n");
//                flag[0] = false;
//            }
            if (flag[0]) {
                havedTrueRows++;
                /**将成果存入入Map**/
                map.put(fruitDTO.getName(), fruitDTO);
            }
        }
        //如果全部正确
        if(allRows == havedTrueRows){
            for (String key : map.keySet()) {
                fruitDTOList.add(map.get(key));
            }
            if(!CollectionUtils.isEmpty(fruitDTOList)){
                this.saveFruitAndOrgRel(fruitDTOList);
            }
        }
        return message;
    }

    public boolean buildMustNotNullMessage(Cell cell, boolean[] flag, StringBuilder message, String content){
        if (null == cell || CellType.BLANK.getCode() == cell.getCellType()) {
            message.append(content);
            flag[0] = false;
        }else{
            flag[0] = true;
        }
        return flag[0];
    }

    public boolean buildNotNullMessage(Cell cell){
        return null != cell;
    }

    public void findExistsByNameAndID(StringBuilder message, boolean[] flag, int i, String name, String type, long orgId){
        int munber = fruitRepository.findExistsByNameAndID(name, type, orgId, null, null);
        if (munber > 0) {
            message.append("第" + (i + 1) + "行的报告题名在系统里面已经存在，不需要导入;\n");
            flag[0] = false;
        }
    }

    public void setCompleteMethod(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的" + name +"不能为空;\n")){
            fruitDTO.setCompleteMethod(cell.getStringCellValue().trim());
        }
    }
    public void setName(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的" + name +"不能为空;\n")) {
            fruitDTO.setName(cell.getStringCellValue().trim());
        }
//        this.findExistsByNameAndID(message, flag, i, fruitDTO.getName(), fruitDTO.getType(), fruitDTO.getOrgId());
    }
    public void setEnglishName(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setEnglishName(cell.getStringCellValue().trim());
        }
    }
    public void setKeyword(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setKeyword(cell.getStringCellValue().trim());
        }
    }
    public void setRemark(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setRemark(cell.getStringCellValue().trim());
        }
    }
    public void setSummary(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setSummary(cell.getStringCellValue().trim().length() > 1000 ? cell.getStringCellValue().trim().substring(0, 1000) : cell.getStringCellValue().trim());
        }
    }
    public void setJournalName(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setJournalName(cell.getStringCellValue().trim());
        }
    }
    public void setPubObject(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setPubObject(cell.getStringCellValue().trim());
        }
    }
    public void setClient(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setClient(cell.getStringCellValue().trim());
        }
    }
    public void setField(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setField(cell.getStringCellValue().trim());
        }
    }
    public void setReadNumber(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setReadNumber((int)cell.getNumericCellValue()+"");
        }
    }
    public void setLinkUrl(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的" + name +"不能为空;\n")) {
            fruitDTO.setLinkUrl(cell.getStringCellValue().trim());
        }
    }
    public void setPress(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setPress(cell.getStringCellValue().trim());
        }
    }
    public void setEdition(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setEdition(cell.getStringCellValue().trim());
        }
    }
    public void setIssueNumber(FruitDTO fruitDTO, Cell cell){
        if (cell != null) {
            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                DecimalFormat df = new DecimalFormat("#");
                fruitDTO.setIssueNumber(df.format(cell.getNumericCellValue()));
            } else {
                fruitDTO.setIssueNumber(cell.getStringCellValue().trim());
            }
        }
    }
    public void setIssueNumber(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的" + name +"不能为空;\n")) {
            fruitDTO.setIssueNumber(cell.getStringCellValue().trim());
        }
    }
    public void setIsbn(FruitDTO fruitDTO, Cell cell){
        if (cell != null){
            //isbn存在数字的情况 去除-
            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                DecimalFormat df = new DecimalFormat("#");
                fruitDTO.setIsbn(df.format(cell.getNumericCellValue()));
            } else {
                fruitDTO.setIsbn(cell.getStringCellValue().trim().replaceAll("-", ""));
            }
        }
    }
    public void setOrganizer(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的" + name +"不能为空;\n")) {
            fruitDTO.setOrganizer(cell.getStringCellValue().trim());
        }
    }
    public void setOrganizer(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setOrganizer(cell.getStringCellValue().trim());
        }
    }
    public void setUndertaker(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setUndertaker(cell.getStringCellValue().trim());
        }
    }
    public void setCoorganizer(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setCoorganizer(cell.getStringCellValue().trim());
        }
    }
    public void setCooperator(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setCooperator(cell.getStringCellValue().trim());
        }
    }
    public void setChiefEditor(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setChiefEditor(cell.getStringCellValue().trim());
        }
    }
    public void setMeetingDays(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setMeetingDays((int)cell.getNumericCellValue());
        }
    }
    public void setMeetingDays(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的"+name+"不能为空;\n")){
            fruitDTO.setMeetingDays((int)cell.getNumericCellValue());
        }
    }
    public void setTheme(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setTheme(cell.getStringCellValue().trim());
        }
    }
    public void setTheme(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的会议主题不能为空;\n")){
            fruitDTO.setTheme(cell.getStringCellValue().trim());
        }
    }
    public void setPubPlace(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setPubPlace(cell.getStringCellValue().trim());
        }
    }
    public void setPubPlace(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的举办地点不能为空;\n")){
            fruitDTO.setPubPlace(cell.getStringCellValue().trim());
        }
    }
    public void setAwards(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setAwards(cell.getStringCellValue().trim());
        }
    }
    public void setGrantUnit(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setGrantUnit(cell.getStringCellValue().trim());
        }
    }
    public void setLinkMan(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setLinkMan(cell.getStringCellValue().trim());
        }
    }
    public void setLinkPhoneNumber(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                DecimalFormat df = new DecimalFormat("#");
                fruitDTO.setLinkPhoneNumber(df.format(cell.getNumericCellValue()));
            }
        }
    }
    public void setLinkAddress(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            fruitDTO.setLinkAddress(cell.getStringCellValue().trim());
        }
    }
    public void setContactFunds(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的合同金额不能为空;\n")){
            fruitDTO.setContactFunds(cell.getNumericCellValue()+"");
        }
    }
    public void setApproveFunds(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                fruitDTO.setApproveFunds(cell.getNumericCellValue() + "");
            }
        }
    }
    public void setAllocatedFunds(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                fruitDTO.setAllocatedFunds(cell.getNumericCellValue()+"");
            }
        }
    }
    public void setSelfraisedFunds(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                fruitDTO.setSelfraisedFunds(cell.getNumericCellValue()+"");
            }
        }
    }
    public void setSupportFunds(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                fruitDTO.setSupportFunds(cell.getNumericCellValue()+"");
            }
        }
    }
    public void setSurplusFunds(FruitDTO fruitDTO, Cell cell){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                fruitDTO.setSurplusFunds(cell.getNumericCellValue()+"");
            }
        }
    }
    public void setPubTime(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                fruitDTO.setPubTime(cell.getDateCellValue());
            } else {
                try {
                    fruitDTO.setPubTime(ft.parse(cell.getStringCellValue().trim()));
                } catch (ParseException e) {
                    e.printStackTrace();
//                    message.append("第" + (i + 1) + "行的"+name+"格式不正确;\n");
                    message.append("第" + (i + 1) + "行的"+name+"格式不正确, 请将单元格格式设置为：自定义——>类型——>yyyy/m/d;\n");
                    flag[0] = false;
                }
            }
        }
    }
    public void setDraftTime(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        if (null != cell){
            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                fruitDTO.setDraftTime(cell.getDateCellValue());
            } else {
                try {
                    fruitDTO.setDraftTime(ft.parse(cell.getStringCellValue().trim()));
                } catch (ParseException e) {
                    e.printStackTrace();
                    message.append("第" + (i + 1) + "行的"+name+"格式不正确;\n");
                    flag[0] = false;
                }
            }
        }
    }
    public void setCompletionTime(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                fruitDTO.setCompletionTime(cell.getDateCellValue());
            } else {
                try {
                    fruitDTO.setCompletionTime(ft.parse(cell.getStringCellValue()));
                } catch (ParseException e) {
                    e.printStackTrace();
                    message.append("第" + (i + 1) + "行的"+name+"格式不正确;\n");
                    flag[0] = false;
                }
            }
        }
    }
    public void setReportType(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的报告类型不能为空;\n")){
            //根据报告类型名称获取对应的值
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("ReportType", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setReportType(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的报告类型填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setPublicationLevel(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            //根据刊物类型名称获取对应的值
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("PubLevel", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setPublicationLevel(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的"+name+"填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setPaperType(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            //根据刊物类型名称获取对应的值
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("paperType", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setPaperType(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的"+name+"填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setClientLevel(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("ClientLevel", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setClientLevel(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的"+name+"填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setJournalType(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            //根据刊物类型名称获取对应的值
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("JournalType", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setJournalType(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的"+name+"填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setWriteType(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("WriteType", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setWriteType(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的"+name+"填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setProjectStatus(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("ProgramProcess", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setProjectStatus(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的"+name+"填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setContractCategory(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if (cell != null && CellType.BLANK.getCode() != cell.getCellType()) {
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("ContractCategory", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setContractCategory(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的"+name+"填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setMeetingType(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的会议类型不能为空;\n")){
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("MeetingType", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setMeetingType(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的会议类型填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setMediaType(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的"+name+"不能为空;\n")){
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("MediaType", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setMediaType(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的"+name+"填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setIsForeign(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的"+name+"不能为空;\n")){
            fruitDTO.setIsForeign(("是").equals(cell.getStringCellValue().trim()));
        }
    }
    public void setVisitType(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的"+name+"不能为空;\n")){
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("VisitType", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setVisitType(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的"+name+"填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setBookType(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if(this.buildMustNotNullMessage(cell, flag, message, "第" + (i + 1) + "行的"+name+"不能为空;\n")){
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("bookType", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setBookType(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的"+name+"填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setAwardsLevel(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if (null != cell) {
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("AwardLevel", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setAwardsLevel(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的"+ name +"填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public void setMeetingLevel(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell cell, String name){
        if (null != cell) {
            List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("InclinationsLevel", cell.getStringCellValue().trim());
            if (sysDicts.size() > 0) {
                fruitDTO.setAwardsLevel(sysDicts.get(0).getDvalue());
            } else {
                message.append("第" + (i + 1) + "行的"+ name +"填写错误;\n");
                flag[0] = false;
            }
        }
    }
    public FruitDTO setAuthorOrg(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i, Cell authCell, Cell authOrgCell, boolean isMustNotNull, HashMap<String, FruitDTO> map, HashMap<String, FruitAuthorPO> authorMap){
        FruitAuthorPO fruitAuthorPO = new FruitAuthorPO();
        if(isMustNotNull ? this.buildMustNotNullMessage(authCell, flag, message, "第" + (i + 1) + "行的作者不能为空;\n")
                : this.buildNotNullMessage(authCell)){
            // 同一个excel里，作者重复，则默认为重复数据，否则相同提名报告，按照excel顺序计算作者排名
            if (authorMap.containsKey(fruitDTO.getName() + RegularExpressionUtil.filterSpace(authCell.getStringCellValue()))) {
                message.append("第").append(i + 1).append("行的名称和作者在excel表格重复!;\n");
                flag[0] = false;
            } else {
                String author = RegularExpressionUtil.filterSpace(authCell.getStringCellValue());
                if(CommonUtil.isSpecialChar(author)){
                    message.append("第").append(i + 1).append("行的作者名称包含特殊符号!;\n");
                    flag[0] = false;
                }else{
                    fruitAuthorPO.setAuthor(author);
                    fruitAuthorPO.setOrgId(OrgAccountHelper.getOrgId());
                    //组装查询查询条件，查询该机构下的同名专家或者临时专家信息
                    fruitDTO = getFruitDTO(map, fruitDTO, fruitAuthorPO);
                }
            }
        }
        if(isMustNotNull ? this.buildMustNotNullMessage(authOrgCell, flag, message, "第" + (i + 1) + "行的单位不能为空;\n")
                : this.buildNotNullMessage(authCell)){
            String[] ss = authOrgCell.getStringCellValue().split("\n");
            setAuthorOrg(authorMap, fruitDTO, fruitAuthorPO, ss);
        }
        return fruitDTO;
    }

    private FruitDTO getFruitDTO(HashMap<String, FruitDTO> map, FruitDTO fruitDTO, FruitAuthorPO fruitAuthorPO) {
        setAuthor(fruitAuthorPO);
        /*
         * 判断报告提名在map是否存在，存在则获取对应的作者排名
         * 存在则依次进行排名，否则为第一作者
         * **/
        if (map.containsKey(fruitDTO.getName())) {
            //查找成果对象
            fruitDTO = map.get(fruitDTO.getName());
            fruitAuthorPO.setRanking(fruitDTO.getAuthorPOList().size() + 1);
        } else {
            fruitAuthorPO.setRanking(1);
        }
        return fruitDTO;
    }

    private void setAuthor(FruitAuthorPO fruitAuthorPO) {
        fruitAuthorPO.setOrgId(OrgAccountHelper.getOrgId());
        //组装查询查询条件，查询该机构下的同名专家或者临时专家信息
        ExpertSearchDto searchDto = new ExpertSearchDto();
        searchDto.setAuthor(fruitAuthorPO.getAuthor());
        List<ExpertSearchDto> expertSearchDtos = tempExpertService.searchByName(searchDto);
        //如果该机构下有同名作者，则默认第一个，否则新增临时专家
        if (expertSearchDtos.size() > 0) {
            fruitAuthorPO.setOrgUserId(expertSearchDtos.get(0).getOrgUserId());
            fruitAuthorPO.setIsTemp(expertSearchDtos.get(0).getIsTemp());
        } else {
            TempExpertPo tempExpertPo = new TempExpertPo();
            tempExpertPo.setRealName(RegularExpressionUtil.filterSpace(fruitAuthorPO.getAuthor()));
            tempExpertPo.setOrgID(OrgAccountHelper.getOrgId());
            tempExpertPo = tempExpertService.create(tempExpertPo);
            fruitAuthorPO.setOrgUserId(tempExpertPo.getId());
            fruitAuthorPO.setIsTemp(true);
        }
    }

    private void setAuthorOrg(HashMap<String, FruitAuthorPO> authorMap, FruitDTO fruitDTO, FruitAuthorPO fruitAuthorPO, String[] ss) {
        for (int j = 1; j <= ss.length; j++) {
            //设置作者单位
            FruitAuthorOrgPO fruitAuthorOrgPO = new FruitAuthorOrgPO();
            fruitAuthorOrgPO.setRanking(j);
            fruitAuthorOrgPO.setName(ss[j - 1]);
            fruitAuthorPO.getOrgPOList().add(fruitAuthorOrgPO);
        }
        fruitDTO.getAuthorPOList().add(fruitAuthorPO);
        /**将报告名称+作者名以key值存入authorMap**/
        authorMap.put(fruitDTO.getName() + fruitAuthorPO.getAuthor(), fruitAuthorPO);
    }

    public FruitDTO setExpertOrg(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i,
                             Cell authCell, Cell jobCell, Cell vpCell, Cell authOrgCell,
                             HashMap<String, FruitDTO> map, HashMap<String, FruitAuthorPO> authorMap){
        FruitAuthorPO fruitAuthorPO = new FruitAuthorPO();
        if(this.buildMustNotNullMessage(authCell, flag, message, "第" + (i + 1) + "行的与会专家不能为空;\n")){
            // 同一个excel里，报告+作者重复，则默认为重复数据，否则相同提名报告，按照excel顺序计算作者排名
            if (authorMap.containsKey(fruitDTO.getName() + RegularExpressionUtil.filterSpace(authCell.getStringCellValue()))) {
                message.append("第" + (i + 1) + "行的活动名称和与会专家在excel表格重复!;\n");
                flag[0] = false;
            } else {
                fruitAuthorPO.setAuthor(RegularExpressionUtil.filterSpace(authCell.getStringCellValue()));
                if (null != jobCell) {
                    fruitAuthorPO.setJob(jobCell.getStringCellValue().trim());
                }
                if (null != vpCell) {
                    fruitAuthorPO.setViewPoint(vpCell.getStringCellValue().trim());
                }
                fruitAuthorPO.setOrgId(OrgAccountHelper.getOrgId());
                //组装查询查询条件，查询该机构下的同名专家或者临时专家信息
                fruitDTO = getFruitDTO(map, fruitDTO, fruitAuthorPO);
            }
        }
        if(this.buildMustNotNullMessage(authOrgCell, flag, message, "第" + (i + 1) + "行的专家单位不能为空;\n")) {
            String[] ss = authOrgCell.getStringCellValue().split("\n");
            setAuthorOrg(authorMap, fruitDTO, fruitAuthorPO, ss);
        }
        return fruitDTO;
    }

    public FruitDTO setZyExpertOrg(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i,
                                   Cell leaderAuthorCell, Cell leaderAuthorOrgCell, Cell leaderJobCell,
                                   Cell authorCell, Cell authorOrgCell,
                                   HashMap<String, FruitDTO> map, HashMap<String, FruitAuthorPO> authorMap){

        String[] leaderAuthorCellArr = null;;
        String[] leaderAuthorOrgCellArr = null;;
        String[] leaderJobCellArr = null;
        if(this.buildMustNotNullMessage(leaderAuthorCell, flag, message, "第" + (i + 1) + "行的政府部门参与领导人员不能为空;\n")){
            leaderAuthorCellArr = leaderAuthorCell.getStringCellValue().split("\n");
        }
        if(this.buildMustNotNullMessage(leaderAuthorOrgCell, flag, message, "第" + (i + 1) + "行的政府部门领导人员部门不能为空;\n")) {
            leaderAuthorOrgCellArr = leaderAuthorOrgCell.getStringCellValue().split("\n");
        }
        if(this.buildMustNotNullMessage(leaderJobCell, flag, message, "第" + (i + 1) + "行的政府部门领导人员职务不能为空;\n")) {
            leaderJobCellArr = leaderJobCell.getStringCellValue().split("\n");
        }
        int[] leaderJudgeArr =  new int[]{
                leaderAuthorCellArr == null ? 0: leaderAuthorCellArr.length,
                leaderAuthorOrgCellArr == null ? 0: leaderAuthorOrgCellArr.length,
                leaderJobCellArr == null ? 0: leaderJobCellArr.length,
        };
        if (!judge(leaderJudgeArr)) {
            message.append("第" + (i + 1) + "行的政府部门参与领导人员、部门、职务数量不匹配;\n");
            flag[0] = false;
        }
        String[] authorCellArr= null;
        String[] authorOrgCellArr = null;
        if(this.buildMustNotNullMessage(authorCell, flag, message, "第" + (i + 1) + "行的研究院参与人不能为空;\n")) {
            authorCellArr = authorCell.getStringCellValue().split("\n");
        }
        if(this.buildMustNotNullMessage(authorOrgCell, flag, message, "第" + (i + 1) + "行的研究院参与人部门不能为空;\n")) {
            authorOrgCellArr = authorOrgCell.getStringCellValue().split("\n");
        }
        int[] authorJudgeArr =  new int[]{
                authorCellArr == null ? 0: authorCellArr.length,
                authorOrgCellArr == null ? 0: authorOrgCellArr.length
        };
        if (!judge(authorJudgeArr)) {
            message.append("第" + (i + 1) + "行的研究院参与人、部门数量不匹配;\n");
            flag[0] = false;
        }
        List<FruitAuthorPO> fruitAuthorPOList = new ArrayList<>();
        for (int m = 1; m <= leaderAuthorCellArr.length; m++) {
            //设置作者单位
            FruitAuthorPO fruitAuthorPO = new FruitAuthorPO();
            fruitAuthorPO.setAuthor(leaderAuthorCellArr[m - 1]);
            fruitAuthorPO.setOrgId(OrgAccountHelper.getOrgId());
            fruitAuthorPO.setJob(leaderJobCellArr[m - 1]);
            fruitAuthorPO.setRanking(m);
            //设置作者单位
            FruitAuthorOrgPO fruitAuthorOrgPO = new FruitAuthorOrgPO();
            fruitAuthorOrgPO.setRanking(1);
            fruitAuthorOrgPO.setName(leaderAuthorOrgCellArr[m - 1]);
            fruitAuthorPO.getOrgPOList().add(fruitAuthorOrgPO);

            fruitAuthorPOList.add(fruitAuthorPO);
        }
        for (int n = 1; n <= authorCellArr.length; n++) {
            //设置作者单位
            FruitAuthorPO fruitAuthorPO = new FruitAuthorPO();
            fruitAuthorPO.setAuthor(authorCellArr[n - 1]);
            fruitAuthorPO.setRanking(leaderAuthorCellArr.length + n);
            fruitAuthorPO.setOrgId(OrgAccountHelper.getOrgId());
            //设置作者单位
            FruitAuthorOrgPO fruitAuthorOrgPO = new FruitAuthorOrgPO();
            fruitAuthorOrgPO.setRanking(1);
            fruitAuthorOrgPO.setName(authorOrgCellArr[n - 1]);
            fruitAuthorPO.getOrgPOList().add(fruitAuthorOrgPO);

            fruitAuthorPOList.add(fruitAuthorPO);
        }
        fruitDTO.setAuthorPOList(fruitAuthorPOList);

        return fruitDTO;
    }

    public FruitDTO setSubAndAdopt(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i,
                                   Cell subTimes, Cell subLevel, Cell subDep, Cell cyCell){
        List<Cell> subObjList = new ArrayList<>();
        subObjList.add(subLevel);
        subObjList.add(subDep);
        subObjList.add(subTimes);
        boolean subValidate = true;
        String[] level = null;;
        String[] dep = null;;
        String[] time = null;
        Date subDate = null;
        //判断list属性是否为空-- 都有值:0  部分为空:1   全部为空:2
        int subBlankData = this.isAllBlank(subObjList);
        if(subBlankData == 1){
            message.append("第" + (i + 1) + "行的报送信息不完整;\n");
            flag[0] = false;
        }else if(subBlankData == 0){
            level = subLevel.getStringCellValue().split("\n");
            dep = subDep.getStringCellValue().split("\n");
            if (CellType.NUMERIC.getCode() == subTimes.getCellType()) {
                subDate = subTimes.getDateCellValue();
                String subTime = subTimes.getDateCellValue().toString();
                time = new String[]{subTime};
            } else {
                time = subTimes.getStringCellValue().split("\n");
            }

            int[] s =  new int[]{level.length, dep.length, time.length};
            if (!judge(s)) {
                subValidate = false;
                message.append("第" + (i + 1) + "行的报送信息数量不匹配;\n");
                flag[0] = false;
            }
        }
        //采用
        boolean cyValidate= true;
        //是否为空
        int cyBlankData = 2;
        String[] cy = null;
        if(cyCell != null && CellType.BLANK.getCode() != cyCell.getCellType()){
            cyBlankData = 0;
            cy = cyCell.getStringCellValue().split("\n");
            //采用有 报送没有
            if(subBlankData == 2){
                message.append("第" + (i + 1) + "行的报送信息与采用信息数量不匹配;\n");
                flag[0] = false;
            }else if(subBlankData == 0){
                //都有值 比较数量是否一致
                int[] compareArr =  new int[]{dep.length, cy.length};
                if (!judge(compareArr)) {
                    cyValidate = false;
                    message.append("第" + (i + 1) + "行的报送信息与采用信息数量不匹配，若无采用信息，对应行请填写'无';\n");
                    flag[0] = false;
                }
            }
        }
        // 报送采用都有值且验证通过
        if(subBlankData == 0 && cyBlankData == 0 && subValidate && cyValidate){
            List<FruitSubPO> subList = fruitDTO.getSubList();
            for (int j = 0; j < dep.length; j++) {
                FruitSubPO fruitSubPO = new FruitSubPO();
                List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("InclinationsLevel", level[j]);
                fruitSubPO.setLevel(!CollectionUtils.isEmpty(sysDicts)? sysDicts.get(0).getDvalue() : "");
                fruitSubPO.setSubDeparment(dep[j]);
                fruitSubPO.setIsAdopt(false);
                if (null != subDate) {
                    fruitSubPO.setSubTime(subDate);
                } else {
                    try {
                        Date nd = new SimpleDateFormat("yyyy/MM/dd").parse(time[j]);
                        fruitSubPO.setSubTime(nd);
                    } catch (ParseException e) {
                        e.printStackTrace();
                        message.append("第" + (i + 1) + "行的报送发日期格式不正确;\n");
                        flag[0] = false;

                    }
                }
                if(!("无").equals(cy[j])){
                    fruitSubPO.setIsAdopt(true);
                    fruitSubPO.setAdoptDeparment(cy[j].split("——")[0]);
                    try {
                        fruitSubPO.setAdoptTime(new SimpleDateFormat("yyyy/MM/dd").parse(cy[j].split("——")[1]));
                    } catch (ParseException e) {
                        e.printStackTrace();
                        message.append("第" + (i + 1) + "行的采用日期格式不正确\n");
                        flag[0] = false;

                    }
                    fruitSubPO.setAdoptJournal(cy[j].split("——")[2]);
                    fruitSubPO.setRemark(("无").equals(cy[j].split("——")[3]) ? "" : cy[j].split("——")[3]);
                }
                subList.add(fruitSubPO);
            }
            fruitDTO.setSubList(subList);
        }

        // 报送都有值且验证通过--采用没有值
        if(subBlankData == 0 && subValidate && cyBlankData == 2){
            List<FruitSubPO> subList = fruitDTO.getSubList();
            for (int j = 0; j < dep.length; j++) {
                FruitSubPO fruitSubPO = new FruitSubPO();
                List<SysDict> sysDicts = sysdictService.findByTypeKeyAndName("InclinationsLevel", level[j]);
                fruitSubPO.setLevel(!CollectionUtils.isEmpty(sysDicts)? sysDicts.get(0).getDvalue() : "");
                fruitSubPO.setSubDeparment(dep[j]);
                fruitSubPO.setIsAdopt(false);
                if (null != subDate) {
                    fruitSubPO.setSubTime(subDate);
                } else {
                    try {
                        Date nd = new SimpleDateFormat("yyyy/MM/dd").parse(time[j]);
                        fruitSubPO.setSubTime(nd);
                    } catch (ParseException e) {
                        e.printStackTrace();
                        message.append("第" + (i + 1) + "行的报送发日期格式不正确;\n");
                        flag[0] = false;

                    }
                }
                subList.add(fruitSubPO);
            }
            fruitDTO.setSubList(subList);
        }
        return fruitDTO;
    }

    public FruitDTO setLeader(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i,
                          Cell leaderName, Cell leaderUnit, Cell leaderJob, Cell leaderLevel, Cell leaderType, Cell leaderTime){
        List<Cell> leaderObjList = new ArrayList<>();
        leaderObjList.add(leaderName);
        leaderObjList.add(leaderUnit);
        leaderObjList.add(leaderJob);
        leaderObjList.add(leaderLevel);
        leaderObjList.add(leaderType);
        leaderObjList.add(leaderTime);
        //判断list属性是否为空-- 都有值:0  部分为空:1   全部为空:2
        int leaderBlankData = this.isAllBlank(leaderObjList);
        if(leaderBlankData == 1){
            message.append("第" + (i + 1) + "行的批示信息不完整;\n");
            flag[0] = false;
        }else if(leaderBlankData == 0){
            String[] pName = leaderName.getStringCellValue().split("\n");
            String[] pUnit = leaderUnit.getStringCellValue().split("\n");
            String[] pJob = leaderJob.getStringCellValue().split("\n");
            String[] pLevel = leaderLevel.getStringCellValue().split("\n");
            String[] pType = leaderType.getStringCellValue().split("\n");
            String[] pTime;
            Date psDate = null;
            if (CellType.NUMERIC.getCode() == leaderTime.getCellType()) {
                psDate = leaderTime.getDateCellValue();
                String psTime = leaderTime.getDateCellValue().toString();
                pTime = new String[]{psTime};
            } else {
                pTime = leaderTime.getStringCellValue().split("\n");
            }
            int[] pArr = new int[]{pName.length, pUnit.length, pJob.length, pLevel.length, pType.length, pTime.length};
            boolean psSuc = true;
            if (!judge(pArr)) {
                psSuc = false;
                message.append("第" + (i + 1) + "行的批示信息数量不匹配，若为空，请填写'无';\n");
                flag[0] = false;
            }
            if(psSuc){
                List<FruitLeaderPO> leaderPOList = fruitDTO.getLeaderPOS();
                for (int j = 0; j < pName.length; j++) {
                    FruitLeaderPO fruitLeaderPO = new FruitLeaderPO();
                    fruitLeaderPO.setName(pName[j]);
                    fruitLeaderPO.setUnit(pUnit[j]);
                    fruitLeaderPO.setJob(pJob[j]);
                    List<SysDict> sysDictsLev = sysdictService.findByTypeKeyAndName("InclinationsLevel", pLevel[j]);
                    fruitLeaderPO.setInclinationLevel(!CollectionUtils.isEmpty(sysDictsLev)? sysDictsLev.get(0).getDvalue() : "");
                    List<SysDict> sysDictInc = sysdictService.findByTypeKeyAndName("Inclinations", pType[j]);
                    fruitLeaderPO.setInclination(!CollectionUtils.isEmpty(sysDictInc)? sysDictInc.get(0).getDvalue() : "");

                    if (null != psDate) {
                        fruitLeaderPO.setInclinationTime(psDate);
                    } else {
                        try {
                            Date nd = new SimpleDateFormat("yyyy/MM/dd").parse(pTime[j]);
                            fruitLeaderPO.setInclinationTime(nd);
                        } catch (ParseException e) {
                            e.printStackTrace();
                            message.append("第" + (i + 1) + "行的批示时间格式不正确;\n");
                            flag[0] = false;
                        }
                    }
                    leaderPOList.add(fruitLeaderPO);
                }
                fruitDTO.setLeaderPOS(leaderPOList);
            }
        }
        return fruitDTO;
    }

    public FruitDTO setMember(FruitDTO fruitDTO, StringBuilder message, boolean[] flag, int i,
                          Cell memberName, Cell memberOrgName, Cell memberJobTitle, Cell memberEducation, Cell memberUndertakeType){
        String[] memberNames = null;
        if(null != memberName){
            memberNames = memberName.getStringCellValue().split("\n");
        }
        String[] memberOrgNames = null;
        if(null != memberOrgName){
            memberOrgNames = memberOrgName.getStringCellValue().split("\n");
        }
        String[] memberJobTitles = null;
        if(null != memberJobTitle){
            memberJobTitles = memberJobTitle.getStringCellValue().split("\n");
        }
        String[] memberEducations = null;
        if(null != memberEducation){
            memberEducations = memberEducation.getStringCellValue().split("\n");
        }
        String[] memberUndertakeTypes = null;
        if(null != memberUndertakeType){
            memberUndertakeTypes = memberUndertakeType.getStringCellValue().split("\n");
        }
        int[] s =  new int[]{
                memberNames == null ? 0: memberNames.length,
                memberOrgNames == null ? 0: memberOrgNames.length,
                memberJobTitles == null ? 0: memberJobTitles.length,
                memberEducations == null ? 0: memberEducations.length,
                memberUndertakeTypes == null ? 0: memberUndertakeTypes.length
        };
        if (!judge(s)) {
            message.append("第" + (i + 1) + "行的项目成员信息数量不匹配;\n");
            flag[0] = false;
        }
        if(memberNames != null){
            List<FruitMemberPO> memberPOList = new ArrayList<>();
            for (int j = 0; j < memberNames.length; j++) {
                FruitMemberPO fruitMemberPO = new FruitMemberPO();
                fruitMemberPO.setName(memberNames[j]);
                fruitMemberPO.setOrgName(memberOrgNames != null ? memberOrgNames[j] : "");
                fruitMemberPO.setJobTitle(memberJobTitles != null ? memberJobTitles[j] : "");
                fruitMemberPO.setEducation(memberEducations != null ? memberEducations[j] : "");
                fruitMemberPO.setUndertakeType(memberUndertakeTypes != null ? memberUndertakeTypes[j] : "");
                memberPOList.add(fruitMemberPO);
            }
            fruitDTO.setMemberList(memberPOList);
        }
        return fruitDTO;
    }


    /**
     * @param message
     * @param sheet
     * @ClassName FruitServiceImpi
     * @Description : 通过excel导入承担项目
     * @Return : java.lang.StringBuilder
     */
    private void projectInformation(StringBuilder message, Sheet sheet, String activityProdType) {
        /**key的值为报告题名，用来保存成果信息**/
        HashMap<String, FruitDTO> map = new HashMap<>();
        /**key的值为报告题名+作者名称，用来判断excel数据是否重复，保存报告对应的作者信息**/
        HashMap<String, FruitAuthorPO> authorMap = new HashMap<>();
        List<FruitDTO> fruitDTOList = new ArrayList<>();
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
        // 是否全部格式正确数量
        int allRows = sheet.getLastRowNum() - 1;
        // 已有格式正确数量
        int havedTrueRows = 0;
        // 获取每行中的字段,过滤首行说明和第二行字段信息
        for (int i = 2; i <= sheet.getLastRowNum(); i++) {
            boolean[] flag = {true};
            FruitDTO fruitDTO = new FruitDTO();
            //如果是自设课题 默认设置类别
            if(ComConstant.FruitType.SELFSET.equals(activityProdType)){
                fruitDTO.setProjectTypeParent("8");
            }
            fruitDTO.setIsPublic("0");
            fruitDTO.setOrgId(OrgAccountHelper.getOrgId());
            fruitDTO.setType(ComConstant.FruitType.PROJECT);
            fruitDTO.setIsSpecialSub("1");
            fruitDTO.setActivityProdType(activityProdType);
            Row row = sheet.getRow(i);
            if (isRowEmpty(row)) {
                allRows -=1 ;
                continue;
            }
            //----------纵向项目-------纵向  国家高端  省重点   自设------
            if(ComConstant.FruitType.VERTICAL.equals(activityProdType) ||
                    ComConstant.FruitType.PROVINCEFOUCS.equals(activityProdType) ||
                    ComConstant.FruitType.HIGHFOUCS.equals(activityProdType) ||
                    ComConstant.FruitType.SELFSET.equals(activityProdType) ){

                // 获取项目名称
                this.setName(fruitDTO, message, flag, i, row.getCell(0), "项目名称");
                // 获取项目级别
                this.setClientLevel(fruitDTO, message, flag, i, row.getCell(1), "项目级别");
                // 获取项目来源单位
                this.setOrganizer(fruitDTO, row.getCell(2));

                FruitAuthorPO fruitAuthorPO = new FruitAuthorPO();
                // 获取项目负责人
                if (null == row.getCell(3)) {
                    message.append("第" + (i + 1) + "行的项目负责人不能为空;\n");
                    flag[0] = false;
                } else {
                    /**同一个excel里，名称+负责人重复，则默认为重复数据，否则相同名称项目，按照execl顺序计算负责人排名**/
                    if (authorMap.containsKey(fruitDTO.getName() + RegularExpressionUtil.filterSpace(row.getCell(3).getStringCellValue()))) {
                        message.append("第" + (i + 1) + "行的项目名称和负责人在excel表格重复!;\n");
                        flag[0] = false;
                    } else {
                        fruitAuthorPO.setAuthor(RegularExpressionUtil.filterSpace(row.getCell(3).getStringCellValue()));
                        if (null != row.getCell(5)) {
                            Cell cell = row.getCell(5);
                            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                                DecimalFormat df = new DecimalFormat("#");
                                fruitAuthorPO.setPhoneNumber(df.format(cell.getNumericCellValue()));
                            }
                        }
                        fruitAuthorPO.setOrgId(OrgAccountHelper.getOrgId());
                        //组装查询查询条件，查询该机构下的同名专家或者临时专家信息
                        fruitDTO = getFruitDTO(map, fruitDTO, fruitAuthorPO);
                    }
                }
                // 获取负责人单位
                if (null == row.getCell(4)) {
                    message.append("第" + (i + 1) + "行的负责人单位不能为空;\n");
                    flag[0] = false;
                } else {
                    String[] ss = row.getCell(4).getStringCellValue().split("\n");
                    setAuthorOrg(authorMap, fruitDTO, fruitAuthorPO, ss);
                }
                // 获取项目这状态
                this.setProjectStatus(fruitDTO, message, flag, i, row.getCell(6), "项目状态");
                // 获取起始时间
                this.setPubTime(fruitDTO, message, flag, i, row.getCell(7), "起始时间");
                //获取结项时间
                this.setDraftTime(fruitDTO, message, flag, i, row.getCell(8), "结项时间");
                //获取截止时间
                this.setCompletionTime(fruitDTO, message, flag, i, row.getCell(9), "截止时间");
                // 获取项目批准经费(万元)
                this.setApproveFunds(fruitDTO, row.getCell(10));
                // 获取已拨经费(万元)
                this.setAllocatedFunds(fruitDTO, row.getCell(11));
                // 获取自筹经费(万元)
                this.setSelfraisedFunds(fruitDTO, row.getCell(12));
                // 获取配套经费(万元)
                this.setSupportFunds(fruitDTO, row.getCell(13));
                // 获取结余经费(万元)
                this.setSurplusFunds(fruitDTO, row.getCell(14));
                // 获取备注
                this.setRemark(fruitDTO, row.getCell(15));
                //获取合同成员
                fruitDTO = this.setMember(fruitDTO, message, flag, i, row.getCell(16), row.getCell(17), row.getCell(18), row.getCell(19), row.getCell(20));

            }else if(("6").equals(activityProdType)){
                //----------横向项目-------------

                // 获取项目名称
                this.setName(fruitDTO, message, flag, i, row.getCell(0), "项目名称");
                // 获取项目类别
                this.setContractCategory(fruitDTO, message, flag, i, row.getCell(1), "项目类别");
                // 获取项目状态
                this.setProjectStatus(fruitDTO, message, flag, i, row.getCell(2), "项目状态");
                // 获取合同编号
                this.setIssueNumber(fruitDTO, message, flag, i, row.getCell(3), "合同编号");
                // 获取合同签订日期
                this.setPubTime(fruitDTO, message, flag, i, row.getCell(4), "合同签订日期");
                // 获取合同金额
                this.setContactFunds(fruitDTO, message, flag, i, row.getCell(5));

                FruitAuthorPO fruitAuthorPO = new FruitAuthorPO();
                // 获取项目负责人
                if (null == row.getCell(6)) {
                    message.append("第" + (i + 1) + "行的项目负责人不能为空;\n");
                    flag[0] = false;
                } else {
                    /**同一个excel里，名称+负责人重复，则默认为重复数据，否则相同名称项目，按照execl顺序计算负责人排名**/
                    if (authorMap.containsKey(fruitDTO.getName() + RegularExpressionUtil.filterSpace(row.getCell(6).getStringCellValue()))) {
                        message.append("第" + (i + 1) + "行的项目名称和负责人在excel表格重复!;\n");
                        flag[0] = false;
                    } else {
                        fruitAuthorPO.setAuthor(RegularExpressionUtil.filterSpace(row.getCell(6).getStringCellValue()));
                        if (null != row.getCell(8)) {
                            Cell cell = row.getCell(8);
                            if (CellType.NUMERIC.getCode() == cell.getCellType()) {
                                DecimalFormat df = new DecimalFormat("#");
                                fruitAuthorPO.setPhoneNumber(df.format(cell.getNumericCellValue()));
                            }
                        }
                        fruitAuthorPO.setOrgId(OrgAccountHelper.getOrgId());
                        //组装查询查询条件，查询该机构下的同名专家或者临时专家信息
                        fruitDTO = getFruitDTO(map, fruitDTO, fruitAuthorPO);
                    }
                }
                // 获取负责人单位
                if (null == row.getCell(7)) {
                    message.append("第" + (i + 1) + "行的负责人单位不能为空;\n");
                    flag[0] = false;
                } else {
                    String[] ss = row.getCell(7).getStringCellValue().split("\n");
                    setAuthorOrg(authorMap, fruitDTO, fruitAuthorPO, ss);
                }

                // 获取甲方名称
                this.setOrganizer(fruitDTO, message, flag, i, row.getCell(9), "甲方名称");
                // 获取甲方联系人
                this.setLinkMan(fruitDTO, row.getCell(10));
                // 获取甲方联系电话
                this.setLinkPhoneNumber(fruitDTO, row.getCell(11));
                // 获取甲方联系地址
                this.setLinkAddress(fruitDTO, row.getCell(12));
                // 获取开始日期
                this.setPubTime(fruitDTO, message, flag, i, row.getCell(13), "开始日期");
                // 获取结束日期
                this.setCompletionTime(fruitDTO, message, flag, i, row.getCell(13), "结束日期");
                // 获取项目批准经费(万元)
                this.setApproveFunds(fruitDTO, row.getCell(15));
                // 获取已拨经费(万元)
                this.setAllocatedFunds(fruitDTO, row.getCell(16));
                // 获取自筹经费(万元)
                this.setSelfraisedFunds(fruitDTO, row.getCell(17));
                // 获取配套经费(万元)
                this.setSupportFunds(fruitDTO, row.getCell(18));
                // 获取结余经费(万元)
                this.setSurplusFunds(fruitDTO, row.getCell(19));
                // 获取备注
                this.setRemark(fruitDTO, row.getCell(20));
                //获取合同成员
                fruitDTO = this.setMember(fruitDTO, message, flag, i, row.getCell(21), row.getCell(22), row.getCell(23), row.getCell(24), row.getCell(25));

            }
            // 判断是否重复
//            if(this.importFruitIsExist(fruitDTO.getType(), fruitDTO)){
//                message.append("第" + (i + 1) + "行的成果数据跟已有成果列表中的数据重复,若仍需导入,请手动添加！;\n");
//                flag[0] = false;
//            }
            if (flag[0]) {
                havedTrueRows++;
                // 将成果存入入Map
                map.put(fruitDTO.getName(), fruitDTO);
            }
        }
        //如果全部正确
        if(allRows == havedTrueRows){
            for (String key : map.keySet()) {
                fruitDTOList.add(map.get(key));
            }
            if(!CollectionUtils.isEmpty(fruitDTOList)){
                this.saveFruitAndOrgRel(fruitDTOList);
            }
        }
    }

    //判断list属性是否为空-- 都有值:0  部分为空:1   全部为空:2
    private int isAllBlank(List<Cell> dataList){
        int flag = 0;
        for (Cell cell : dataList) {
            if(cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK){
                flag += 1;
            }
        }
        //都有值:0  部分为空:1   全部为空:2
        if(flag == 0){
            return 0;
        }else if(flag == dataList.size()){
            return 2;
        }

        return 1;
    }


    /**
     * 一维数组 值互相比较是否相等
     * @param s
     * @return
     */
    private boolean judge(int[] s) {
        boolean[] flag = {true};
        loop:
        for (int i = 0; i < s.length; i++) {
            for (int j = i + 1; j < s.length; j++) {
                if (s[i] != s[j]) {
                    flag[0] = false;
                    break loop;
                }
            }
        }
        return flag[0];
    }



    /**
     * 保存成果及 机构与成果的对应关系
     * @param fruitDTOList
     */
    @Transactional(rollbackFor = Exception.class)
    public void saveFruitAndOrgRel(List<FruitDTO> fruitDTOList){
        try {
            fruitDTOList.forEach(fruitDTO -> {
                //数据是否已经存在，替换不为空的数据
                FruitPO oldFruit = this.importFruitIsExist(fruitDTO.getType(), fruitDTO);
                FruitDTO oldFruitDTO = fruitMapper.po2dto(oldFruit);
                if(oldFruit != null){
                    BeanUtil.copyProperties(fruitDTO, oldFruitDTO,
                            CopyOptions.create().setIgnoreError(true).setIgnoreNullValue(true).setIgnoreError(true)
                    );
                    //设置作者
                    List<FruitAuthorPO> newAuthorPOList = new ArrayList<>();
                    fruitDTO.getAuthorPOList().forEach(newAuthorPO-> {
                        FruitAuthorPO fruitAuthorPO = new FruitAuthorPO();
                        BeanUtils.copyProperties(newAuthorPO, fruitAuthorPO);
                        fruitAuthorPO.setId(null);
                        fruitAuthorPO.setFruitId(oldFruit.getId());
                        //设置作者单位
                        List<FruitAuthorOrgPO> newAuthorOrgPOList = new ArrayList<>();
                        newAuthorPO.getOrgPOList().forEach(newAuthorOrgPO -> {
                            FruitAuthorOrgPO fruitAuthorOrgPO = new FruitAuthorOrgPO();
                            BeanUtils.copyProperties(newAuthorOrgPO, fruitAuthorOrgPO);
                            fruitAuthorOrgPO.setId(null);
                            fruitAuthorOrgPO.setAuthorId(null);
                            newAuthorOrgPOList.add(fruitAuthorOrgPO);
                        });
                        fruitAuthorPO.setOrgPOList(newAuthorOrgPOList);
                        fruitAuthorPO = fruitAuthorRepository.saveAndFlush(fruitAuthorPO);

                        newAuthorPOList.add(fruitAuthorPO);
                    });
                    if(!CollectionUtils.isEmpty(oldFruitDTO.getAuthorPOList())){
                        //删除旧的数据
                        oldFruitDTO.getAuthorPOList().forEach(oldAuthorPO -> {
                            fruitAuthorRepository.delete(oldAuthorPO);
                        });
                    }

                    oldFruitDTO.getAuthorPOList().clear();
                    oldFruitDTO.getAuthorPOList().addAll(newAuthorPOList);

                    //设置报送
                    List<FruitSubPO> subPOList = new ArrayList<>();
                    fruitDTO.getSubList().forEach(newSubPo-> {
                        FruitSubPO fruitSubPO = new FruitSubPO();
                        BeanUtils.copyProperties(newSubPo, fruitSubPO);
                        fruitSubPO.setId(null);
                        fruitSubPO.setFruitId(oldFruit.getId());
                        fruitSubPO = fruitSubRepository.saveAndFlush(fruitSubPO);

                        subPOList.add(fruitSubPO);
                    });
                    if(!CollectionUtils.isEmpty(oldFruitDTO.getSubList())) {
                        //删除旧的数据
                        oldFruitDTO.getSubList().forEach(oldSubPO -> {
                            fruitSubRepository.delete(oldSubPO);
                        });
                    }
                    oldFruitDTO.getSubList().clear();
                    oldFruitDTO.getSubList().addAll(subPOList);

                    //设置批示
                    List<FruitLeaderPO> leaderPOList = new ArrayList<>();
                    fruitDTO.getLeaderPOS().forEach(newLeaderPO -> {
                        FruitLeaderPO fruitLeaderPO = new FruitLeaderPO();
                        BeanUtils.copyProperties(newLeaderPO, fruitLeaderPO);
                        fruitLeaderPO.setId(null);
                        fruitLeaderPO.setFruitId(oldFruit.getId());
                        fruitLeaderPO = fruitLeaderRepository.saveAndFlush(fruitLeaderPO);

                        leaderPOList.add(fruitLeaderPO);
                    });
                    if(!CollectionUtils.isEmpty(oldFruitDTO.getLeaderPOS())) {
                        //删除旧的数据
                        oldFruitDTO.getLeaderPOS().forEach(oldLeaderPO -> {
                            fruitLeaderRepository.delete(oldLeaderPO);
                        });
                    }
                    oldFruitDTO.getLeaderPOS().clear();
                    oldFruitDTO.getLeaderPOS().addAll(leaderPOList);

                    fruitRepository.save(fruitMapper.dto2po(oldFruitDTO));
                }else{
                    FruitPO fruitPo = fruitRepository.save(fruitMapper.dto2po(fruitDTO));
                    fruitPo.setInitFruitId(fruitPo.getId());
                    fruitRepository.save(fruitPo);

                    if(!CollectionUtils.isEmpty(fruitPo.getSubList())) {
                        fruitPo.getSubList().forEach(subPO -> {
                            subPO.setFruitId(fruitPo.getInitFruitId());
                            fruitSubRepository.save(subPO);
                        });
                    }

                    if(!CollectionUtils.isEmpty(fruitPo.getLeaderPOS())) {
                        fruitPo.getLeaderPOS().forEach(leaderPO -> {
                            leaderPO.setFruitId(fruitPo.getInitFruitId());
                            fruitLeaderRepository.save(leaderPO);
                        });
                    }

                    FruitOrgRelPo fruitOrgRelPo = new FruitOrgRelPo();
                    fruitOrgRelPo.setOrgId(fruitPo.getOrgId());
                    fruitOrgRelPo.setStatus("1");
                    fruitOrgRelPo.setFruitId(fruitPo.getId());
                    fruitOrgRelPo.setInitFruitId(fruitPo.getInitFruitId());
                    fruitOrgRelRepository.save(fruitOrgRelPo);
                    //设置成果关键字
//                    wordcloudService.deleteByFruitId(fruitPo.getId());
//                    wordcloudService.create(fruitPo.getId());
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setFruitNewVal(FruitDTO oldPO, FruitDTO newPO){
        oldPO.setName(newPO.getName());
        oldPO.setPubTime(newPO.getPubTime());
        switch (oldPO.getType()) {
            case ComConstant.FruitType.InternalReferenceReport:
                oldPO.setCompleteMethod(newPO.getCompleteMethod());
                oldPO.setKeyword(newPO.getKeyword());

                oldPO.setAuthorPOList(newPO.getAuthorPOList());
                oldPO.setSubList(newPO.getSubList());
                oldPO.setLeaderPOS(newPO.getLeaderPOS());
                break;
            case ComConstant.FruitType.REPORT:
                oldPO.setReportType(newPO.getReportType());
                oldPO.setCompletionTime(newPO.getCompletionTime());
                oldPO.setKeyword(newPO.getKeyword());
                oldPO.setSummary(newPO.getSummary());
                oldPO.setPublicationLevel(newPO.getPublicationLevel());
                oldPO.setJournalName(newPO.getJournalName());
                oldPO.setOrganizer(newPO.getOrganizer());

                oldPO.setAuthorPOList(newPO.getAuthorPOList());
                oldPO.setLeaderPOS(newPO.getLeaderPOS());
                break;
            case ComConstant.FruitType.PolicyAdvice:
//                if(("1").equals(oldPO.getActivityProdType())){
//                    oldPO.setReportType(newPO.getReportType());
//                    oldPO.setEnglishName(newPO.getEnglishName());
//                    oldPO.setOrganizer(newPO.getOrganizer());
//                    oldPO.setUndertaker(newPO.getUndertaker());
//                    oldPO.setCoorganizer(newPO.getCoorganizer());
//                    oldPO.setCooperator(newPO.getCooperator());
//                    oldPO.setTheme(newPO.getTheme());
//                    oldPO.setPubPlace(newPO.getPubPlace());
//                    oldPO.setAwardsLevel(newPO.getAwardsLevel());
//                    oldPO.setMeetingDays(newPO.getMeetingDays());
//                    oldPO.setRemark(newPO.getRemark());
//
//                    oldPO.setAuthorPOList(newPO.getAuthorPOList());
//
//                }else if(("2").equals(activityProdType)){
//                    //----------接待来访-------------
//                    // 获取访问类型
//                    this.setVisitType(fruitDTO, message, flag, i, row.getCell(0), "访问类型");
//                    // 获取来访主题
//                    this.setName(fruitDTO, message, flag, i, row.getCell(1), "考察调研主题");
//                    // 获取组织单位
//                    this.setOrganizer(fruitDTO, message, flag, i, row.getCell(2), "组织单位");
//                    // 获取关键词
//                    this.setKeyword(fruitDTO, row.getCell(3));
//                    // 获取来访日期
//                    this.setPubTime(fruitDTO, message, flag, i, row.getCell(4), "来访日期");
//                    // 获取来访级别
//                    this.setAwardsLevel(fruitDTO, message, flag, i, row.getCell(5), "来访级别");
//                    // 获取作者+单位
//                    fruitDTO = setAuthorOrg(fruitDTO, message, flag, i, row.getCell(6), row.getCell(7), false, map, authorMap);
//                    // 获取摘要
//                    this.setSummary(fruitDTO, row.getCell(8));
//                    // 获取来访内容
//                    this.setField(fruitDTO, row.getCell(9));
//                    // 获取备注
//                    this.setRemark(fruitDTO, row.getCell(10));
//
//                }else if(("3").equals(activityProdType)) {
//                    //----------考察调研-------------
//                    // 获取访问类型
//                    this.setVisitType(fruitDTO, message, flag, i, row.getCell(0), "访问类型");
//                    // 获取考察调研主题
//                    this.setName(fruitDTO, message, flag, i, row.getCell(1), "考察调研主题");
//                    // 获取组织单位
//                    this.setOrganizer(fruitDTO, message, flag, i, row.getCell(2), "组织单位");
//                    // 获取接待单位
//                    this.setUndertaker(fruitDTO, row.getCell(3));
//                    // 获取考察调研时间
//                    this.setPubTime(fruitDTO, message, flag, i, row.getCell(4), "考察调研时间");
//                    // 获取考察调研天数
//                    this.setMeetingDays(fruitDTO, message, flag, i, row.getCell(5), "考察调研天数");
//                    // 获取考察调研级别
//                    this.setAwardsLevel(fruitDTO, message, flag, i, row.getCell(6), "考察调研级别");
//                    // 获取考察调研负责人
//                    this.setChiefEditor(fruitDTO, row.getCell(7));
//                    // 获取考察调研内容
//                    this.setSummary(fruitDTO, row.getCell(8));
//                    // 获取考察调研对象
//                    this.setPubObject(fruitDTO, row.getCell(9));
//                    // 获取备注
//                    this.setRemark(fruitDTO, row.getCell(10));
//
//                }else if(("4").equals(activityProdType)) {
//                    //----------授课培训-------------
//                    // 获取培训名称
//                    this.setName(fruitDTO, message, flag, i, row.getCell(0), "培训名称");
//                    // 获取培训主题
//                    this.setTheme(fruitDTO, row.getCell(1));
//                    // 获取开始时间
//                    this.setPubTime(fruitDTO, message, flag, i, row.getCell(2), "开始时间");
//                    // 获取授课培训天数
//                    this.setMeetingDays(fruitDTO, row.getCell(3));
//                    // 获取主办单位
//                    this.setOrganizer(fruitDTO, message, flag, i, row.getCell(4), "主办单位");
//                    // 获取承办单位
//                    this.setUndertaker(fruitDTO, row.getCell(5));
//                    // 获取协办单位
//                    this.setCoorganizer(fruitDTO, row.getCell(6));
//                    // 获取合作单位
//                    this.setCooperator(fruitDTO, row.getCell(7));
//                    // 获取作者+单位
//                    fruitDTO = setAuthorOrg(fruitDTO, message, flag, i, row.getCell(8), row.getCell(9), false, map, authorMap);
//                    // 获取培训对象
//                    this.setPubObject(fruitDTO, row.getCell(10));
//                    // 获取培训级别
//                    this.setAwardsLevel(fruitDTO, message, flag, i, row.getCell(11), "培训级别");
//                    // 获取委托单位
//                    this.setClient(fruitDTO, row.getCell(12));
//                    // 获取参与人数
//                    this.setReadNumber(fruitDTO, row.getCell(13));
//                    // 获取培训地点
//                    this.setPubPlace(fruitDTO, row.getCell(14));
//                    // 获取主要内容
//                    this.setSummary(fruitDTO, row.getCell(15));
//                    // 获取备注
//                    this.setRemark(fruitDTO, row.getCell(16));
//                }
                break;
            case ComConstant.FruitType.NewspaperORNetwork:
                break;
            case ComConstant.FruitType.Paper:
                break;
            case ComConstant.FruitType.BOOK:
                break;
            case ComConstant.FruitType.PRICE:
                break;
            case ComConstant.FruitType.PROJECT:
                break;
        }
//
//
//        oldFruit.setMemberList(fruitDTO.getMemberList());
//        oldFruit.setSubprojectList(fruitDTO.getSubprojectList());
    }

    private static boolean isRowEmpty(Row row) {
        if(row != null){
            for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) {
                Cell cell = row.getCell(i);
                if (cell != null && cell.getCellType() != CellType.BLANK.getCode()) {
                    return false;
                }
            }
        }
        return true;
    }

    /**
     * 导入成果检测是否重复
     * @param type
     * @param fruitDTO
     * @return
     */
    public FruitPO importFruitIsExist(String type, FruitDTO fruitDTO){
        FruitDTO searchDTO = new FruitDTO();
        Set<Long> orgIdList = new HashSet<>();
        orgIdList.add(OrgAccountHelper.getOrgId());
        searchDTO.setOrgIdList(orgIdList);
        searchDTO.setType(type);
        searchDTO.setName(fruitDTO.getName());
        if(ComConstant.FruitType.BOOK.equals(type)){
            searchDTO.setPress(fruitDTO.getPress());
            searchDTO.setIsbn(fruitDTO.getIsbn());
        }else if(ComConstant.FruitType.PolicyAdvice.equals(type)){
            if(("1").equals(fruitDTO.getActivityProdType())){
                searchDTO.setMeetingType(fruitDTO.getMeetingType());
            }else if(("2").equals(fruitDTO.getActivityProdType())){
                searchDTO.setOrganizer(fruitDTO.getOrganizer());
            }else if(("3").equals(fruitDTO.getActivityProdType())){
                searchDTO.setVisitType(fruitDTO.getVisitType());
            }
        }else if(ComConstant.FruitType.NewspaperORNetwork.equals(type)){
            searchDTO.setJournalName(fruitDTO.getJournalName());
        }else if(ComConstant.FruitType.PRICE.equals(type)){
            searchDTO.setAwards(fruitDTO.getAwards());
        }

        List<FruitPO> fruitPOList = fruitServiceImpl.getOrgFruitData(searchDTO, null);
        if(!CollectionUtils.isEmpty(fruitPOList)){
           return fruitPOList.get(0);
        }
        return null;
    }

    @Override
    public List<Map<String, String>> getExcelFields(@RequestBody FruitDTO searchDto) {
        List<Map<String, String>> mapLists = new ArrayList();
        Field[] fields = null;
        switch (searchDto.getType()) {
            case "1":
                fields = ContinuousData.class.getDeclaredFields();
                break;
            case "2":
                fields = InternalReference.class.getDeclaredFields();
                break;
            case "3":
                fields = Report.class.getDeclaredFields();
                break;
            case "4":
                fields = PolicyAdvice.class.getDeclaredFields();
                if(("1").equals(searchDto.getActivityProdType())){
                    fields = PolicyAdviceMeeting.class.getDeclaredFields();
                }else if(("2").equals(searchDto.getActivityProdType())){
                    fields = PolicyAdviceVisit.class.getDeclaredFields();
                }else if(("3").equals(searchDto.getActivityProdType())){
                    fields = PolicyAdviceSurvey.class.getDeclaredFields();
                }else if(("4").equals(searchDto.getActivityProdType())){
                    fields = PolicyAdviceTrain.class.getDeclaredFields();
                }
                break;
            case "5":
                if(("10").equals(searchDto.getActivityProdType())){
                    fields = Media.class.getDeclaredFields();
                }else if(("11").equals(searchDto.getActivityProdType())){
                    fields = PolicyAdviceInterview.class.getDeclaredFields();
                }
                break;
            case "6":
                fields = Paper.class.getDeclaredFields();
                break;
            case "7":
                fields = Book.class.getDeclaredFields();
                break;
            case "8":
                fields = Honor.class.getDeclaredFields();
                break;
            case "10":
                fields = ProjectVertical.class.getDeclaredFields();
                if(("5").equals(searchDto.getActivityProdType())){
                    fields = ProjectVertical.class.getDeclaredFields();
                }else if(("6").equals(searchDto.getActivityProdType())){
                    fields = ProjectHorizontal.class.getDeclaredFields();
                }
                break;
            default:
                fields = OtherPublications.class.getDeclaredFields();
        }
        //每个内部类-获取所有属性（不包括父类的）
        for (Field fd : fields) {
            //存放desc和key的map
            Map<String, String> descKeyMap = new LinkedHashMap<String, String>();
            //每个属性获取指定的annotation的注解对象
            ConstantAnnotation ca = fd.getAnnotation(ConstantAnnotation.class);
            if (ca != null) {
                //注解对象不空，其值为注解对象中的值
                descKeyMap.put("fieldText", ca.value());
                descKeyMap.put("fieldName", fd.getName());
                mapLists.add(descKeyMap);
            }
        }
        return mapLists;
    }

    @Override
    public void exportFruit(FruitParamsDTO fruitParamsDTO, String[] splitData, List<FruitPO> list, String exportType, HttpServletResponse response) throws IOException {

        //组装需要导出的数据
        List<Object[]> dataList = new ArrayList<Object[]>();
        //组装excel列头名称--基础字段
//        String[] rowsBasicName = new String[splitData.length];
        List<String> rowsBasicName = new ArrayList<>();
        //组装excel列头名称--集合字段
//        String[] rowsListName = new String[splitData.length];
        List<String> rowsListName = new ArrayList<>();

        Field[] fields = null;

        switch (fruitParamsDTO.getSearchDto().getType()) {
            case "1":
                fields = ContinuousData.class.getDeclaredFields();
                break;
            case "2":
                fields = InternalReference.class.getDeclaredFields();
                break;
            case "3":
                fields = Report.class.getDeclaredFields();
                break;
            case "4":
                fields = PolicyAdvice.class.getDeclaredFields();
                if(("1").equals(fruitParamsDTO.getSearchDto().getActivityProdType())){
                    fields = PolicyAdviceMeeting.class.getDeclaredFields();
                }else if(("2").equals(fruitParamsDTO.getSearchDto().getActivityProdType())){
                    fields = PolicyAdviceVisit.class.getDeclaredFields();
                }else if(("3").equals(fruitParamsDTO.getSearchDto().getActivityProdType())){
                    fields = PolicyAdviceSurvey.class.getDeclaredFields();
                }else if(("4").equals(fruitParamsDTO.getSearchDto().getActivityProdType())){
                    fields = PolicyAdviceTrain.class.getDeclaredFields();
                }
                break;
            case "5":
                if(("10").equals(fruitParamsDTO.getSearchDto().getActivityProdType())){
                    fields = Media.class.getDeclaredFields();
                }else if(("11").equals(fruitParamsDTO.getSearchDto().getActivityProdType())){
                    fields = PolicyAdviceInterview.class.getDeclaredFields();
                }
                break;
            case "6":
                fields = Paper.class.getDeclaredFields();
                break;
            case "7":
                fields = Book.class.getDeclaredFields();
                break;
            case "8":
                fields = Honor.class.getDeclaredFields();
                break;
            case "10":
                fields = ProjectVertical.class.getDeclaredFields();
                if(("5").equals(fruitParamsDTO.getSearchDto().getActivityProdType())){
                    fields = ProjectVertical.class.getDeclaredFields();
                }else if(("6").equals(fruitParamsDTO.getSearchDto().getActivityProdType())){
                    fields = ProjectHorizontal.class.getDeclaredFields();
                }
                break;
            default:
                fields = OtherPublications.class.getDeclaredFields();
        }
        int rowBasicIndex = 0;
        int rowListIndex = 0;
        //创建新的字段数组  用于过滤list字段
        List<String> tempDataArr = new ArrayList<>();
        for (String filedName : splitData) {
            for (Field filed : fields) {
                ConstantAnnotation ca = filed.getAnnotation(ConstantAnnotation.class);
                //如果前台选择名称和excel导出字段名称相同，则获取对应的excel表头信息
                if (filed.getName().equals(filedName) && !("subInfo").equals(filedName) && !("leaderInfo").equals(filedName)) {
                    if (null != ca) {
                        String title = ca.value();
                        rowsBasicName.add(title);
                        tempDataArr.add(filedName);
                        //导出含有作者时  默认添加作者单位
                        if(("作者").equals(title) || ("与会专家").equals(title) || ("采访专家").equals(title) || ("来访专家").equals(title)){
                            rowsBasicName.add("单位");
                            tempDataArr.add("authorOrg");
                        }
//                        rowsBasicName[rowBasicIndex++] = title;
                    }
                }else if (filed.getName().equals(filedName) && (("subInfo").equals(filedName) || ("leaderInfo").equals(filedName))){
                    if (null != ca) {
                        String title = ca.value();
                        rowsListName.add(title);
//                        rowsListName[rowListIndex++] = title;
                    }
                }
            }
        }
        for (int i = 0; i < list.size(); i++) {
            FruitPO fruitPO = list.get(i);
            Object[] objs = new Object[rowsBasicName.size() + rowsListName.size()];
            for (int j = 0; j < rowsBasicName.size(); j++) {
                //如果前台选择作者字段，需要特殊处理
                if (tempDataArr.get(j).equals("author")) {
                    //如果作者信息不为空，则循环获取作者信息及单位信息
                    objs[j] = fruitPO.getAuthorPOList();
                }else if (tempDataArr.get(j).equals("memberList")) {
                    //如果项目成员信息不为空，则循环获取项目成员信息
                    StringBuilder stringBuilder = new StringBuilder();
                    if (null != fruitPO.getMemberList() && fruitPO.getMemberList().size() > 0) {
                        for (FruitMemberPO fruitMemberPO : fruitPO.getMemberList()) {
                            stringBuilder.append(fruitMemberPO.getName() + "-"
                                    + fruitMemberPO.getOrgName() + "-"
                                    + fruitMemberPO.getJobTitle() + "-"
                                    + fruitMemberPO.getEducation() + "-"
                                    + fruitMemberPO.getUndertakeType() + "\t\r\n");
                        }
                    }
                    objs[j] = stringBuilder;
                } else if (tempDataArr.get(j).equals("subprojectList")) {
                    //如果批示信息不为空，则循环获取批示信息
                    StringBuilder stringBuilder = new StringBuilder();
                    if (null != fruitPO.getSubprojectList() && fruitPO.getSubprojectList().size() > 0) {
                        for (FruitSubprojectrPO fruitSubprojectrPO : fruitPO.getSubprojectList()) {
                            stringBuilder.append(fruitSubprojectrPO.getName() + "-"
                                    + fruitSubprojectrPO.getUserName() + "-"
                                    + fruitSubprojectrPO.getOrgName() + "-"
                                    + fruitSubprojectrPO.getFunds() + "\t\r\n");
                        }
                    }
                    objs[j] = stringBuilder;
                } else {
                    //其他字段根据字段名称选择
                    if (null == ReflexObjectUtil.getValueByKey(fruitPO, tempDataArr.get(j))) {
                        objs[j] = "";
                    } else {
                        objs[j] = ReflexObjectUtil.getValueByKey(fruitPO, tempDataArr.get(j)).toString();
                    }
                }
            }
            //报送 + 批示信息
            for (int k = 0; k < rowsListName.size(); k++) {
                if (("报送信息").equals(rowsListName.get(k))) {
                    objs[rowsBasicName.size()+k] = fruitPO.getSubList();
                } else if (("批示信息").equals(rowsListName.get(k))) {
                    objs[rowsBasicName.size()+k] = fruitPO.getLeaderPOS();
                }
            }
            dataList.add(objs);
        }

        HSSFWorkbook workbook = new HSSFWorkbook();
        // 创建工作簿对象
        String title = "成果导出表";
        HSSFSheet sheet = workbook.createSheet(title);
        OutputStream outputStream = response.getOutputStream();
        try {
            ExportExcel ex = new ExportExcel(title, rowsBasicName, rowsListName, dataList);
            if(("1").equals(exportType)){
                ex.export(workbook, sheet, 0);
            }else if(("2").equals(exportType)){
                ex.exportDataInOneCell(workbook, sheet, 0);
            }
            // HSSFWorkbook写入流
            workbook.write(outputStream);
        }catch (Exception e){
            e.printStackTrace();
            log.error("导出专家成果情况失败:", e);
        }finally {
            // 刷新流
            outputStream.flush();
            // 关闭流
            outputStream.close();
        }
    }

    public static void main(String[] args) {
        String a = "";
        String b = "";
        List<String> list = new ArrayList<>();
        list.add(a);
        list.add(b);

        list.forEach(str-> System.out.println(str));
    }
}
